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