1
0
forked from MTSR/mapserver

config api

This commit is contained in:
NatureFreshMilk 2019-01-18 11:09:16 +01:00
parent b74e9da1c1
commit 8ed4e4be4a
2 changed files with 17 additions and 0 deletions

16
web/config.go Normal file
View File

@ -0,0 +1,16 @@
package web
import (
"encoding/json"
"mapserver/app"
"net/http"
)
type ConfigHandler struct {
ctx *app.App
}
func (h *ConfigHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
resp.Header().Add("content-type", "application/json")
json.NewEncoder(resp).Encode(h.ctx.Config)
}

View File

@ -19,6 +19,7 @@ func Serve(ctx *app.App) {
mux.Handle("/", http.FileServer(vfs.FS(ctx.Config.Webdev)))
mux.Handle("/api/tile/", &Tiles{ctx: ctx})
mux.Handle("/api/config", &ConfigHandler{ctx: ctx})
if ctx.Config.WebApi.EnableMapblock {
mux.Handle("/api/mapblock/", &MapblockHandler{ctx: ctx})