1
0
forked from MTSR/mapserver
mapserver/server/web/config.go

29 lines
577 B
Go
Raw Normal View History

2019-01-18 13:09:16 +03:00
package web
import (
"encoding/json"
"mapserver/app"
2019-02-07 10:02:13 +03:00
"mapserver/layer"
2019-01-18 13:09:16 +03:00
"net/http"
)
2019-02-07 10:02:13 +03:00
//Public facing config
type PublicConfig struct {
2019-02-14 10:50:54 +03:00
Layers []*layer.Layer `json:"layers"`
2019-02-12 15:40:33 +03:00
MapObjects *app.MapObjectConfig `json:"mapobjects"`
2019-02-07 10:02:13 +03:00
}
2019-01-18 13:09:16 +03:00
type ConfigHandler struct {
ctx *app.App
}
func (h *ConfigHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
resp.Header().Add("content-type", "application/json")
2019-02-07 10:02:13 +03:00
webcfg := PublicConfig{}
webcfg.Layers = h.ctx.Config.Layers
2019-02-12 15:40:33 +03:00
webcfg.MapObjects = h.ctx.Config.MapObjects
2019-02-07 10:02:13 +03:00
json.NewEncoder(resp).Encode(webcfg)
2019-01-18 13:09:16 +03:00
}