diff --git a/web/config.go b/web/config.go new file mode 100644 index 0000000..7b526c8 --- /dev/null +++ b/web/config.go @@ -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) +} diff --git a/web/serve.go b/web/serve.go index eefdca5..2004af4 100644 --- a/web/serve.go +++ b/web/serve.go @@ -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})