config api
This commit is contained in:
parent
b74e9da1c1
commit
8ed4e4be4a
16
web/config.go
Normal file
16
web/config.go
Normal 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)
|
||||||
|
}
|
@ -19,6 +19,7 @@ func Serve(ctx *app.App) {
|
|||||||
|
|
||||||
mux.Handle("/", http.FileServer(vfs.FS(ctx.Config.Webdev)))
|
mux.Handle("/", http.FileServer(vfs.FS(ctx.Config.Webdev)))
|
||||||
mux.Handle("/api/tile/", &Tiles{ctx: ctx})
|
mux.Handle("/api/tile/", &Tiles{ctx: ctx})
|
||||||
|
mux.Handle("/api/config", &ConfigHandler{ctx: ctx})
|
||||||
|
|
||||||
if ctx.Config.WebApi.EnableMapblock {
|
if ctx.Config.WebApi.EnableMapblock {
|
||||||
mux.Handle("/api/mapblock/", &MapblockHandler{ctx: ctx})
|
mux.Handle("/api/mapblock/", &MapblockHandler{ctx: ctx})
|
||||||
|
Loading…
Reference in New Issue
Block a user