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 11:05:39 +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
|
|
|
}
|