diff pkg/controllers/system.go @ 3104:19fc84a98479

Added "published-config" field to configuration. It's a path to a published JSON file (after login) to give additional parameters to the client. Reached by GET /api/system/config Currently the field "osm-url" is used by the client to determine the URL of the OSM server for the background layer.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 25 Apr 2019 15:31:43 +0200
parents a244b18cb916
children 8a4fb02ee60a
line wrap: on
line diff
--- a/pkg/controllers/system.go	Thu Apr 25 13:11:41 2019 +0200
+++ b/pkg/controllers/system.go	Thu Apr 25 15:31:43 2019 +0200
@@ -14,12 +14,14 @@
 package controllers
 
 import (
+	"bytes"
 	"database/sql"
 	"fmt"
 	"io/ioutil"
 	"net/http"
 	"strings"
 
+	"gemma.intevation.de/gemma/pkg/config"
 	"gemma.intevation.de/gemma/pkg/models"
 	"github.com/gorilla/mux"
 )
@@ -78,6 +80,29 @@
 	return
 }
 
+func getSystemConfig(
+	_ interface{}, req *http.Request,
+	_ *sql.Conn,
+) (jr JSONResult, err error) {
+
+	cfg := config.PublishedConfig()
+	if cfg == "" {
+		err = JSONError{
+			Code:    http.StatusNotFound,
+			Message: "No published configuration found.",
+		}
+		return
+	}
+
+	var data []byte
+	if data, err = ioutil.ReadFile(cfg); err != nil {
+		return
+	}
+
+	jr = JSONResult{Result: bytes.NewReader(data)}
+	return
+}
+
 // Map/Feature style end points
 
 func getFeatureStyle(