mapserver/web/colormapping.go

26 lines
469 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"`
A uint8 `json:"a"`
2019-05-05 18:07:49 +03:00
}
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() {
cm[k] = Color{R: v.R, G: v.G, B: v.B, A: v.A}
2019-05-05 18:07:49 +03:00
}
resp.Header().Add("content-type", "application/json")
json.NewEncoder(resp).Encode(cm)
}