34 lines
777 B
Go
34 lines
777 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"flag"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
|
||
|
"gitlab.codemonkeysoftware.net/b/henwen/back"
|
||
|
"gitlab.codemonkeysoftware.net/b/henwen/front"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
addr := flag.String("address", ":8080", "bind address for HTTP server as host:port")
|
||
|
title := flag.String("title", "Henwen", "website title")
|
||
|
baseURL := flag.String("baseURL", "http://localhost:8080", "base URL for HTTP routes")
|
||
|
dbFileName := flag.String("db", "./henwen.db", "name of database file")
|
||
|
flag.Parse()
|
||
|
|
||
|
store, err := back.NewStore(*dbFileName, back.SecureGenString)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
srv := http.Server{
|
||
|
Addr: *addr,
|
||
|
Handler: front.NewHandler(front.HandlerParams{
|
||
|
Store: store,
|
||
|
Title: *title,
|
||
|
BaseURL: *baseURL,
|
||
|
}),
|
||
|
}
|
||
|
log.Println(srv.ListenAndServe())
|
||
|
}
|