mapserver/server/web/config.go

27 lines
467 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 {
Layers []layer.Layer `json:"layers"`
}
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
json.NewEncoder(resp).Encode(webcfg)
2019-01-18 13:09:16 +03:00
}