Mercurial > gemma
diff pkg/geoserver/boot.go @ 915:2ebf677fc2e1 geo-style
Load style data only on demand to not waste menory.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 03 Oct 2018 13:08:23 +0200 |
parents | 4bf3a3a20ce1 |
children | a244b18cb916 |
line wrap: on
line diff
--- a/pkg/geoserver/boot.go Wed Oct 03 02:04:20 2018 +0200 +++ b/pkg/geoserver/boot.go Wed Oct 03 13:08:23 2018 +0200 @@ -366,6 +366,14 @@ func updateStyle(entry *models.IntEntry, create bool) error { + log.Printf("creating style %s\n", entry.Name) + + // Try to load the style data. + data, err := entry.LoadStyle() + if err != nil { + return err + } + var ( geoURL = config.GeoServerURL() user = config.GeoServerUser() @@ -373,8 +381,6 @@ auth = basicAuth(user, password) ) - log.Printf("creating style %s\n", entry.Name) - styleURL := geoURL + "/rest/workspaces/" + workspaceName + "/styles" @@ -422,12 +428,12 @@ req, err := http.NewRequest( http.MethodPut, styleURL+"/"+url.PathEscape(entry.Name), - strings.NewReader(entry.Style.String)) + strings.NewReader(data)) if err != nil { return err } auth(req) - if isSymbologyEncoding(entry.Style.String) { + if isSymbologyEncoding(data) { asContentType(req, "application/vnd.ogc.se+xml") } else { asContentType(req, "application/vnd.ogc.sld+xml")