Mercurial > gemma
annotate pkg/controllers/system.go @ 2327:ead321473840
schema/gemma.sql: Added to gm_waterlevel bottlenecks_geoserver view.
author | Bjoern Schilberg <bjoern@intevation.de> |
---|---|
date | Tue, 19 Feb 2019 13:45:39 +0100 |
parents | a244b18cb916 |
children | 19fc84a98479 |
rev | line source |
---|---|
1017
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
2 // without warranty, see README.md and license for details. |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
3 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
6 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
9 // Software engineering by Intevation GmbH |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
10 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
11 // Author(s): |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
12 // * Sascha Wilde <sascha.wilde@intevation.de> |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
854
diff
changeset
|
13 |
722
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
14 package controllers |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
15 |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
16 import ( |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
17 "database/sql" |
840
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
18 "fmt" |
722
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
19 "io/ioutil" |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
20 "net/http" |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
21 "strings" |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
22 |
840
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
23 "gemma.intevation.de/gemma/pkg/models" |
722
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
24 "github.com/gorilla/mux" |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
25 ) |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
26 |
840
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
27 const ( |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
28 getFeatureColourSQL = `SELECT r,g,b,a |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
29 FROM systemconf.feature_colours |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
30 WHERE feature_name = $1 AND style_attr = $2` |
846
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
31 setFeatureColourSQL = `UPDATE systemconf.feature_colours |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
32 SET (r, g, b, a) = ($3, $4, $5, $6) |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
33 WHERE feature_name = $1 AND style_attr = $2` |
840
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
34 ) |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
35 |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
36 // System status end points |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
37 |
722
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
38 func showSystemLog( |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
39 _ interface{}, req *http.Request, |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
40 _ *sql.Conn, |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
41 ) (jr JSONResult, err error) { |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
42 |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
43 serviceName := mux.Vars(req)["service"] |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
44 fileName := mux.Vars(req)["file"] |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
45 |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
46 // The following check is currently most likely unnecessary as I wasn't |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
47 // able to inject a verbatim '/' via the middleware, but better be on |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
48 // the safe site... |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
49 if strings.Contains(fileName, "/") { |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
50 err = JSONError{http.StatusBadRequest, |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
51 "error: no slashes allowed in file name"} |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
52 return |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
53 } |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
54 |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
55 var path string |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
56 |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
57 switch serviceName { |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
58 case "apache2", "postgresql": |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
59 path = "/var/log/" + serviceName + "/" + fileName |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
60 default: |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
61 err = JSONError{http.StatusBadRequest, |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
62 "error: invalid service: " + serviceName} |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
63 return |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
64 } |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
65 |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
66 var txt []byte |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
67 |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
68 if txt, err = ioutil.ReadFile(path); err != nil { |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
69 return |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
70 } |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
71 |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
72 jr = JSONResult{ |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
73 Result: struct { |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
74 Path string `json:"path"` |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
75 Content string `json:"content"` |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
76 }{path, string(txt)}, |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
77 } |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
78 return |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
79 } |
840
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
80 |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
81 // Map/Feature style end points |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
82 |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
83 func getFeatureStyle( |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
84 _ interface{}, |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
85 req *http.Request, |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
86 db *sql.Conn, |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
87 ) (jr JSONResult, err error) { |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
88 |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
89 feature := mux.Vars(req)["feature"] |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
90 attr := mux.Vars(req)["attr"] |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
91 |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
92 c := models.Colour{} |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
93 err = db.QueryRowContext( |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
94 req.Context(), |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
95 getFeatureColourSQL, |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
96 feature, attr, |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
97 ).Scan(&c.R, &c.G, &c.B, &c.A) |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
98 |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
99 switch { |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
100 case err == sql.ErrNoRows: |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
101 err = JSONError{ |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
102 Code: http.StatusNotFound, |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
103 Message: "Requestes style not found.", |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
104 } |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
105 return |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
106 case err != nil: |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
107 return |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
108 } |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
109 |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
110 jr.Result = &struct { |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
111 Colour models.Colour `json:"colour"` |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
112 Code string `json:"code"` |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
113 }{c, fmt.Sprintf("rgba(%d, %d, %d, %g)", c.R, c.G, c.B, c.A)} |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
114 return |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
115 } |
846
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
116 |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
117 func setFeatureStyle( |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
118 input interface{}, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
119 req *http.Request, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
120 db *sql.Conn, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
121 ) (jr JSONResult, err error) { |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
122 |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
123 feature := mux.Vars(req)["feature"] |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
124 attr := mux.Vars(req)["attr"] |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
125 |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
126 c := input.(*models.Colour) |
854
83c271cb2344
Reverted fcb38cedc680 (More tightened color model.)
Sascha Wilde <wilde@intevation.de>
parents:
850
diff
changeset
|
127 if !c.IsValid() { |
83c271cb2344
Reverted fcb38cedc680 (More tightened color model.)
Sascha Wilde <wilde@intevation.de>
parents:
850
diff
changeset
|
128 err = JSONError{http.StatusBadRequest, "error: invalid colours"} |
83c271cb2344
Reverted fcb38cedc680 (More tightened color model.)
Sascha Wilde <wilde@intevation.de>
parents:
850
diff
changeset
|
129 return |
83c271cb2344
Reverted fcb38cedc680 (More tightened color model.)
Sascha Wilde <wilde@intevation.de>
parents:
850
diff
changeset
|
130 } |
846
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
131 |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
132 var res sql.Result |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
133 res, err = db.ExecContext( |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
134 req.Context(), |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
135 setFeatureColourSQL, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
136 feature, attr, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
137 c.R, c.G, c.B, c.A) |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
138 |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
139 if err != nil { |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
140 return |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
141 } |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
142 |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
143 if n, err2 := res.RowsAffected(); err2 == nil && n == 0 { |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
144 err = JSONError{ |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
145 Code: http.StatusNotFound, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
146 Message: "Requestes style not found.", |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
147 } |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
148 return |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
149 } |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
150 |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
151 jr = JSONResult{ |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
152 Code: http.StatusCreated, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
153 Result: struct { |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
154 Result string `json:"result"` |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
155 }{"success"}, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
156 } |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
157 return |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
158 } |