1
0
forked from MTSR/mapserver
mapserver/web/colormapping.go

25 lines
441 B
Go
Raw Normal View History

2019-05-05 18:07:49 +03:00
package web
import (
"encoding/json"
"net/http"
)
type Color struct {
R uint8 `json:"r"`
G uint8 `json:"g"`
B uint8 `json:"b"`
}
2021-04-12 14:55:00 +03:00
func (api *Api) GetColorMapping(resp http.ResponseWriter, req *http.Request) {
2019-05-05 18:07:49 +03:00
cm := make(map[string]Color)
2021-04-12 14:55:00 +03:00
for k, v := range api.Context.Colormapping.GetColors() {
2019-05-05 18:07:49 +03:00
cm[k] = Color{R: v.R, G: v.G, B: v.B}
}
resp.Header().Add("content-type", "application/json")
json.NewEncoder(resp).Encode(cm)
}