Add README and WIP server lifecycle

This commit is contained in:
Miguel de la Cruz 2021-09-12 00:32:07 +02:00
parent 96bd6a8602
commit 19a2096193
7 changed files with 118 additions and 2 deletions

22
web/web.go Normal file
View file

@ -0,0 +1,22 @@
package web
import (
"fmt"
"net/http"
)
func NewWebServer(port int) (*http.Server, error) {
mux := http.NewServeMux()
// ToDo: configure routes
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello rmsn!!")
})
s := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: mux,
}
return s, nil
}