diff --git a/app/config.go b/app/config.go index 0ee408b..3e4019f 100644 --- a/app/config.go +++ b/app/config.go @@ -13,7 +13,7 @@ type Config struct { func ParseConfig(filename string) (*Config, error) { cfg := Config{ - Port: 80, + Port: 8080, EnableInitialRendering: true, } diff --git a/main.go b/main.go index ceec6fe..502438b 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "mapserver/initialrenderer" "mapserver/layerconfig" "mapserver/params" + "mapserver/web" "fmt" ) @@ -55,7 +56,10 @@ func main() { //run initial rendering if ctx.Config.EnableInitialRendering { - initialrenderer.Render(ctx.Tilerenderer, layerconfig.DefaultLayers) + go initialrenderer.Render(ctx.Tilerenderer, layerconfig.DefaultLayers) } + //Start http server + web.Serve(ctx) + } diff --git a/web/serve.go b/web/serve.go new file mode 100644 index 0000000..63e60f1 --- /dev/null +++ b/web/serve.go @@ -0,0 +1,27 @@ +package web + +import ( + "github.com/sirupsen/logrus" + "mapserver/app" + "net/http" + "strconv" + "fmt" +) + +func Serve(ctx *app.App){ + fields := logrus.Fields{ + "port": ctx.Config.Port, + } + logrus.WithFields(fields).Info("Starting http server") + + mux := http.NewServeMux() + + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, "Welcome to my website!") + }) + + err := http.ListenAndServe(":" + strconv.Itoa(ctx.Config.Port), mux) + if err != nil { + panic(err) + } +}