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-04-04 13:50:40 +03:00
|
|
|
Version string `json:"version"`
|
|
|
|
Layers []*layer.Layer `json:"layers"`
|
|
|
|
MapObjects *app.MapObjectConfig `json:"mapobjects"`
|
|
|
|
DefaultOverlays []string `json:"defaultoverlays"`
|
2019-04-14 20:17:43 +03:00
|
|
|
EnableSearch bool `json:"enablesearch"`
|
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-03-29 12:18:23 +03:00
|
|
|
webcfg.Version = app.Version
|
2019-04-04 13:50:40 +03:00
|
|
|
webcfg.DefaultOverlays = h.ctx.Config.DefaultOverlays
|
2019-04-14 20:17:43 +03:00
|
|
|
webcfg.EnableSearch = h.ctx.Config.EnableSearch
|
2019-02-07 10:02:13 +03:00
|
|
|
|
|
|
|
json.NewEncoder(resp).Encode(webcfg)
|
2019-01-18 13:09:16 +03:00
|
|
|
}
|