mapserver/web/config.go

31 lines
869 B
Go
Raw Normal View History

2019-01-18 11:09:16 +01:00
package web
import (
"encoding/json"
"mapserver/app"
2019-02-07 08:02:13 +01:00
"mapserver/layer"
2019-01-18 11:09:16 +01:00
"net/http"
)
2019-02-07 08:02:13 +01:00
//Public facing config
type PublicConfig struct {
2019-04-04 12:50:40 +02:00
Version string `json:"version"`
Layers []*layer.Layer `json:"layers"`
MapObjects *app.MapObjectConfig `json:"mapobjects"`
DefaultOverlays []string `json:"defaultoverlays"`
EnableSearch bool `json:"enablesearch"`
2019-02-07 08:02:13 +01:00
}
2021-04-12 13:55:00 +02:00
func (api *Api) GetConfig(resp http.ResponseWriter, req *http.Request) {
2019-01-18 11:09:16 +01:00
resp.Header().Add("content-type", "application/json")
2019-02-07 08:02:13 +01:00
webcfg := PublicConfig{}
2021-04-12 13:55:00 +02:00
webcfg.Layers = api.Context.Config.Layers
webcfg.MapObjects = api.Context.Config.MapObjects
2019-03-29 10:18:23 +01:00
webcfg.Version = app.Version
2021-04-12 13:55:00 +02:00
webcfg.DefaultOverlays = api.Context.Config.DefaultOverlays
webcfg.EnableSearch = api.Context.Config.EnableSearch
2019-02-07 08:02:13 +01:00
json.NewEncoder(resp).Encode(webcfg)
2019-01-18 11:09:16 +01:00
}