1
0
forked from MTSR/mapserver
mapserver/web/colormapping.go
BuckarooBanzay 57ebd896da use
2021-04-12 13:55:00 +02:00

25 lines
441 B
Go

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