i can't find get layerGroup's method, in your code. but i have fix it now by learning your code, thank you very much
type Group struct {
Type string `json:"@type,omitempty" xml:"type"`
Name string `json:"name,omitempty" xml:"name"`
Href string `json:"href,omitempty" xml:"href"`
}
type LayerGroup struct {
Name string `json:"name" xml:"name"`
Mode string `json:"mode" xml:"mode"`
Title string `json:"title" xml:"title"`
Workspace struct {
Name string `json:"name" xml:"name"`
} `json:"workspace" xml:"workspace"`
Publishables struct {
Published []*Group `json:"published" xml:"published"`
} `json:"publishables" xml:"publishables"`
Styles struct {
Style []*Group `json:"style" xml:"style"`
} `json:"styles" xml:"styles"`
Bounds struct {
MinX float64 `json:"minx" xml:"minx"`
MinY float64 `json:"miny" xml:"miny"`
MaxX float64 `json:"maxx" xml:"maxx"`
MaxY float64 `json:"maxy" xml:"maxy"`
Crs string `json:"crs" xml:"crs"`
} `json:"bounds" xml:"bounds"`
}
type LayerGroups struct {
LayerGroup LayerGroup `json:"layerGroup" xml:"layerGroup"`
}
target := utils.Catalog.ParseURL("rest", "workspaces", workspace.Name, "layergroups", "xxxx")
request := geoserver.HTTPRequest{
Method: "GET",
Accept: "application/json",
URL: target,
Query: nil,
}
response, code := utils.Catalog.DoRequest(request)
if code != http.StatusOK {
utils.Logger.Error("get layer groups error", zap.Int("error code", code))
c.JSON(http.StatusInternalServerError, utils.BaseResponse(http.StatusInternalServerError, "internal server error", c.Request.RequestURI, nil))
return
}
var groups defs.LayerGroups
utils.Catalog.DeSerializeJSON(response, &groups)
server := &defs.Server{
BaseServiceUrl: utils.Catalog.ParseURL(workspace.Name, "wms?"),
Layers: fmt.Sprintf("%s:%s", groups.LayerGroup.Workspace.Name, groups.LayerGroup.Name),
TilematrixSet: groups.LayerGroup.Bounds.Crs,
}