diff --git a/cmd/server/main.go b/cmd/server/main.go index c187d24..317d439 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -1,8 +1,8 @@ package main import ( - "fmt" "log" + "net" "net/http" "os" @@ -27,8 +27,12 @@ func main() { ), ), ) - addr := fmt.Sprintf(":%d", conf.Conf.Port) - log.Fatal(http.ListenAndServe(addr, router)) + + listener, err := net.Listen(conf.Conf.Protocol, conf.Conf.Address) + if err != nil { + log.Fatal(err) + } + log.Fatal(http.Serve(listener, router)) } func logger(next http.Handler) http.Handler { diff --git a/conf.toml b/conf.toml index 913dfa3..32651b5 100644 --- a/conf.toml +++ b/conf.toml @@ -1,6 +1,7 @@ extension = "md" notesdir = "saved_notes" -port = 8080 +address = ":8080" +protocol = "tcp" [templates] dir = "templates" diff --git a/internal/conf/conf.go b/internal/conf/conf.go index f8feeec..212129f 100644 --- a/internal/conf/conf.go +++ b/internal/conf/conf.go @@ -53,7 +53,8 @@ func (asset *Asset) FetchIfNotExists(staticPath string) { } type Config struct { - Port int + Address string + Protocol string Extension string NotesDir string Templates struct {