annotate pkg/controllers/routes.go @ 5574:271888ef85bc surveysperbottleneckid

Finalize use of bottleneck id instead of name. Main feaure is the restructuring of the /surveys endpoint. The endpoint now takes queryparameters as qualifiers. /surveys?id={id} returns surveys to a given bottleck {id} /surveys?name={name} & date={date} returns surveys for given {name} of a bottleneck and {date} for a surveydate. This is needed mainly because there is some backwards incompatibility when reviewing sounding results where the summary of a sr import contains only the name instead of the id of the according bottleneck. To bridge this mismatch the survey endpoint could be queried for the sr to review given the surveydate and the name of the bottleneck. Premise is here, that a date and a bottleneck's name is specific enough to identify the correct survey with the correct bottleneck.
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 21 Jul 2021 14:33:35 +0200
parents 8e30b926b94d
children 6709530f002e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1017
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
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: 978
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: 978
diff changeset
3 //
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
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: 978
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: 978
diff changeset
6 //
4894
8eb36d0d5bdf Draft implementation of fairway marks import
Tom Gottfried <tom@intevation.de>
parents: 4800
diff changeset
7 // Copyright (C) 2018, 2020 by via donau
1017
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
diff changeset
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
diff changeset
9 // Software engineering by Intevation GmbH
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
diff changeset
10 //
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
diff changeset
11 // Author(s):
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
diff changeset
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
diff changeset
13 // * Sascha Wilde <sascha.wilde@intevation.de>
a244b18cb916 Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 978
diff changeset
14
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 package controllers
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 import (
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2040
diff changeset
18 "encoding/json"
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 "net/http"
346
ad0e47c1fedf Use httputil.ReverseProxy for WFS proxying.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
20 "net/http/httputil"
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
21 "strings"
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
414
c1047fd04a3a Moved project specific Go packages to new pkg folder.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 408
diff changeset
23 "github.com/gorilla/mux"
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
414
c1047fd04a3a Moved project specific Go packages to new pkg folder.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 408
diff changeset
25 "gemma.intevation.de/gemma/pkg/auth"
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
26 "gemma.intevation.de/gemma/pkg/imports"
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
27 mw "gemma.intevation.de/gemma/pkg/middleware"
442
fc37e7072022 Moved some models used in controllers to to model package because they may be needed elsewhere (e.g. GeoServer config).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 441
diff changeset
28 "gemma.intevation.de/gemma/pkg/models"
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 )
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
1693
cdc8933949f2 Controllers: Resolved the remaining golint issues with this package.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 1677
diff changeset
31 // BindRoutes binds all the API endpoints to the exposed router.
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 func BindRoutes(m *mux.Router) {
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 api := m.PathPrefix("/api").Subrouter()
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
270
d1b0d964af09 Dont restrict listing/updating of users to sys_admins.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 254
diff changeset
36 var (
978
544a5cfe07cd Started with endpoint for uploading sounding result and trigger respective import job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 872
diff changeset
37 sysAdmin = auth.EnsureRole("sys_admin")
544a5cfe07cd Started with endpoint for uploading sounding result and trigger respective import job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 872
diff changeset
38 waterwayAdmin = auth.EnsureRole("waterway_admin")
544a5cfe07cd Started with endpoint for uploading sounding result and trigger respective import job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 872
diff changeset
39 any = auth.EnsureRole("sys_admin", "waterway_admin", "waterway_user")
270
d1b0d964af09 Dont restrict listing/updating of users to sys_admins.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 254
diff changeset
40 )
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41
4747
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
42 // Password resets.
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
43 api.Handle("/users/passwordreset", &mw.JSONHandler{
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
44 Input: func(*http.Request) interface{} { return new(models.PWResetUser) },
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
45 Handle: passwordResetRequest,
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
46 NoConn: true,
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
47 }).Methods(http.MethodPost)
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
48
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
49 api.HandleFunc("/users/passwordreset/{hash}", passwordReset).
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
50 Methods(http.MethodGet)
b1428b44e43f Handle password reset before matching users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4680
diff changeset
51
335
bd292a554b6e Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 304
diff changeset
52 // User management.
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
53 api.Handle("/users", any(&mw.JSONHandler{
250
deabc2712634 Implemented /users GET as list of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 242
diff changeset
54 Handle: listUsers,
deabc2712634 Implemented /users GET as list of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 242
diff changeset
55 })).Methods(http.MethodGet)
deabc2712634 Implemented /users GET as list of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 242
diff changeset
56
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
57 api.Handle("/users", sysAdmin(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
58 Input: func(*http.Request) interface{} { return new(models.User) },
239
713234a04a87 Renamed JSONHandler.Process to JSONHandler.Handler as it sounds more symmetrical.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 237
diff changeset
59 Handle: createUser,
237
3771788d3dae Reduce boilerplate code when writing JSON parsing/generating endpoints.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 235
diff changeset
60 })).Methods(http.MethodPost)
3771788d3dae Reduce boilerplate code when writing JSON parsing/generating endpoints.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 235
diff changeset
61
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
62 api.Handle("/users/{user:.+}", any(&mw.JSONHandler{
254
de6fdb316b8f Implemented /users/{user} GET a listing of given user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 250
diff changeset
63 Handle: listUser,
de6fdb316b8f Implemented /users/{user} GET a listing of given user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 250
diff changeset
64 })).Methods(http.MethodGet)
de6fdb316b8f Implemented /users/{user} GET a listing of given user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 250
diff changeset
65
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
66 api.Handle("/users/{user:.+}", any(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
67 Input: func(*http.Request) interface{} { return new(models.User) },
239
713234a04a87 Renamed JSONHandler.Process to JSONHandler.Handler as it sounds more symmetrical.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 237
diff changeset
68 Handle: updateUser,
237
3771788d3dae Reduce boilerplate code when writing JSON parsing/generating endpoints.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 235
diff changeset
69 })).Methods(http.MethodPut)
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70
5345
95dafb72a288 Added a PATCH endpoint for /api/users/{user}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5327
diff changeset
71 api.Handle("/users/{user:.+}", any(&mw.JSONHandler{
95dafb72a288 Added a PATCH endpoint for /api/users/{user}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5327
diff changeset
72 Input: func(*http.Request) interface{} { return new(models.UserPatch) },
95dafb72a288 Added a PATCH endpoint for /api/users/{user}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5327
diff changeset
73 Handle: patchUser,
95dafb72a288 Added a PATCH endpoint for /api/users/{user}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5327
diff changeset
74 })).Methods(http.MethodPatch)
95dafb72a288 Added a PATCH endpoint for /api/users/{user}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5327
diff changeset
75
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
76 api.Handle("/users/{user:.+}", sysAdmin(&mw.JSONHandler{
240
9012e4045da4 Implemented /user delete controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 239
diff changeset
77 Handle: deleteUser,
242
24eb518b0394 /users delete should be handled by HTTP DELETE not PUT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 240
diff changeset
78 })).Methods(http.MethodDelete)
240
9012e4045da4 Implemented /user delete controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 239
diff changeset
79
822
8926c413db21 Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents: 812
diff changeset
80 // System notifications
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
81 api.Handle("/testmail/{user:.+}", sysAdmin(&mw.JSONHandler{
822
8926c413db21 Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents: 812
diff changeset
82 Handle: sendTestMail,
8926c413db21 Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents: 812
diff changeset
83 })).Methods(http.MethodGet)
8926c413db21 Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents: 812
diff changeset
84
722
815f5e2ed974 Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents: 710
diff changeset
85 // System Management
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
86 api.Handle("/system/log/{service}/{file}", sysAdmin(&mw.JSONHandler{
722
815f5e2ed974 Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents: 710
diff changeset
87 Handle: showSystemLog,
815f5e2ed974 Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents: 710
diff changeset
88 NoConn: true,
815f5e2ed974 Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents: 710
diff changeset
89 })).Methods(http.MethodGet)
815f5e2ed974 Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents: 710
diff changeset
90
840
0f61bfc21041 Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents: 822
diff changeset
91 // System Settings
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
92 api.Handle("/system/config", any(&mw.JSONHandler{
3104
19fc84a98479 Added "published-config" field to configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
93 Handle: getSystemConfig,
19fc84a98479 Added "published-config" field to configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
94 NoConn: true,
19fc84a98479 Added "published-config" field to configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
95 })).Methods(http.MethodGet)
19fc84a98479 Added "published-config" field to configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
96
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
97 api.Handle("/system/settings", any(&mw.JSONHandler{
3625
a688a478e35f implemented configuration backend and frontend
Markus Kottlaender <markus@intevation.de>
parents: 3439
diff changeset
98 Handle: getSystemSettings,
a688a478e35f implemented configuration backend and frontend
Markus Kottlaender <markus@intevation.de>
parents: 3439
diff changeset
99 })).Methods(http.MethodGet)
a688a478e35f implemented configuration backend and frontend
Markus Kottlaender <markus@intevation.de>
parents: 3439
diff changeset
100
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
101 api.Handle("/system/settings", sysAdmin(&mw.JSONHandler{
3628
6693be57b7a2 Re-worked the Go part a little bit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3625
diff changeset
102 Input: func(*http.Request) interface{} { return &map[string]string{} },
3625
a688a478e35f implemented configuration backend and frontend
Markus Kottlaender <markus@intevation.de>
parents: 3439
diff changeset
103 Handle: setSystemSettings,
a688a478e35f implemented configuration backend and frontend
Markus Kottlaender <markus@intevation.de>
parents: 3439
diff changeset
104 })).Methods(http.MethodPut)
a688a478e35f implemented configuration backend and frontend
Markus Kottlaender <markus@intevation.de>
parents: 3439
diff changeset
105
2147
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
106 // Print templates
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
107 api.Handle("/templates", any(&mw.JSONHandler{
2147
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
108 Handle: listPrintTemplates,
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
109 })).Methods(http.MethodGet)
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
110
3217
4c254651d80b Added template types "map", "diagram", "report".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3171
diff changeset
111 tTypes := "{type:" + strings.Join(templateTypes, "|") + "}"
4c254651d80b Added template types "map", "diagram", "report".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3171
diff changeset
112
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
113 api.Handle("/templates/"+tTypes, any(&mw.JSONHandler{
3217
4c254651d80b Added template types "map", "diagram", "report".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3171
diff changeset
114 Handle: listPrintTemplates,
4c254651d80b Added template types "map", "diagram", "report".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3171
diff changeset
115 })).Methods(http.MethodGet)
4c254651d80b Added template types "map", "diagram", "report".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3171
diff changeset
116
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
117 api.Handle("/templates/"+tTypes+"/{name}", any(&mw.JSONHandler{
2147
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
118 Handle: fetchPrintTemplate,
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
119 })).Methods(http.MethodGet)
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
120
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
121 api.Handle("/templates/"+tTypes+"/{name}", waterwayAdmin(&mw.JSONHandler{
2161
7444b75d5497 Print templates endpoints: Get rid of useless models.PrintTemplateIn model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2155
diff changeset
122 Input: func(*http.Request) interface{} { return &json.RawMessage{} },
2147
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
123 Handle: createPrintTemplate,
2155
51c5aead78c0 Print templates: Implemented /api/templates/print/{name} GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2147
diff changeset
124 Limit: maxPrintTemplateSize,
2147
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
125 })).Methods(http.MethodPost)
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
126
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
127 api.Handle("/templates/"+tTypes+"/{name}", waterwayAdmin(&mw.JSONHandler{
2147
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
128 Handle: deletePrintTemplate,
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
129 })).Methods(http.MethodDelete)
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
130
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
131 api.Handle("/templates/"+tTypes+"/{name}", waterwayAdmin(&mw.JSONHandler{
2162
0627565fb4d2 Print templates: Implemented /api/templates/print/{name} PATCH to update print templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2161
diff changeset
132 Input: func(*http.Request) interface{} { return &json.RawMessage{} },
2147
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
133 Handle: updatePrintTemplate,
2162
0627565fb4d2 Print templates: Implemented /api/templates/print/{name} PATCH to update print templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2161
diff changeset
134 Limit: maxPrintTemplateSize,
2147
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
135 })).Methods(http.MethodPatch)
b66cfcde8ff7 Print templates: Stubbed endpoints under /api/templates/print/{name}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2073
diff changeset
136
426
4a03d000c854 Fixed wrong comments.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 421
diff changeset
137 // External proxies.
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
138 external := mw.NotFound(&httputil.ReverseProxy{
442
fc37e7072022 Moved some models used in controllers to to model package because they may be needed elsewhere (e.g. GeoServer config).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 441
diff changeset
139 Director: proxyDirector(models.ExternalServices.Find),
421
c37457f12b8e Differ between internal and external proxies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 419
diff changeset
140 ModifyResponse: proxyModifyResponse("/api/external/"),
1127
71ba4a66ec95 Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1051
diff changeset
141 })
346
ad0e47c1fedf Use httputil.ReverseProxy for WFS proxying.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
142
472
39b5deee8810 Replaced 'all' by 'any' in routes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 443
diff changeset
143 externalAuth := any(external)
443
5e8ac1c67fe6 Even the usage of the external proxied WFS/WMS need to logged into gemma.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 442
diff changeset
144
5e8ac1c67fe6 Even the usage of the external proxied WFS/WMS need to logged into gemma.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 442
diff changeset
145 api.Handle("/external/{hash}/{url}", externalAuth).
408
ac23905e64b1 Improve WFS proxy a lot. It now generates signed re-writings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 359
diff changeset
146 Methods(
ac23905e64b1 Improve WFS proxy a lot. It now generates signed re-writings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 359
diff changeset
147 http.MethodGet, http.MethodPost,
ac23905e64b1 Improve WFS proxy a lot. It now generates signed re-writings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 359
diff changeset
148 http.MethodPut, http.MethodDelete)
ac23905e64b1 Improve WFS proxy a lot. It now generates signed re-writings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 359
diff changeset
149
443
5e8ac1c67fe6 Even the usage of the external proxied WFS/WMS need to logged into gemma.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 442
diff changeset
150 api.Handle("/external/{entry}", externalAuth).
335
bd292a554b6e Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 304
diff changeset
151 Methods(
bd292a554b6e Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 304
diff changeset
152 http.MethodGet, http.MethodPost,
bd292a554b6e Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 304
diff changeset
153 http.MethodPut, http.MethodDelete)
bd292a554b6e Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 304
diff changeset
154
426
4a03d000c854 Fixed wrong comments.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 421
diff changeset
155 // Internal proxies.
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
156 internal := mw.NotFound(&httputil.ReverseProxy{
474
11d80120ed3d Renamed published services to internal services to be more symmetrical to external services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 473
diff changeset
157 Director: proxyDirector(models.InternalServices.Find),
421
c37457f12b8e Differ between internal and external proxies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 419
diff changeset
158 ModifyResponse: proxyModifyResponse("/api/internal/"),
1127
71ba4a66ec95 Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1051
diff changeset
159 })
419
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
160
472
39b5deee8810 Replaced 'all' by 'any' in routes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 443
diff changeset
161 internalAuth := any(
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
162 mw.ModifyQuery(internal, mw.InjectUser))
419
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
163
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
164 api.Handle("/internal/{hash}/{url}", internalAuth).
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
165 Methods(
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
166 http.MethodGet, http.MethodPost,
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
167 http.MethodPut, http.MethodDelete)
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
168
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
169 api.Handle("/internal/{entry}", internalAuth).
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
170 Methods(
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
171 http.MethodGet, http.MethodPost,
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
172 http.MethodPut, http.MethodDelete)
6627c48363a0 First attempt for user injection of proxy for using GeoServer with role based security.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 414
diff changeset
173
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
174 api.Handle("/published", any(&mw.JSONHandler{
473
b2dea4e56ff1 /api/published (GET) returns a JSON document of the geo-services published by the gemma server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 472
diff changeset
175 Handle: published,
486
b2dc9c2f69e0 First stab to use the metamorphic db to do all database stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 484
diff changeset
176 NoConn: true,
473
b2dea4e56ff1 /api/published (GET) returns a JSON document of the geo-services published by the gemma server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 472
diff changeset
177 })).Methods(http.MethodGet)
b2dea4e56ff1 /api/published (GET) returns a JSON document of the geo-services published by the gemma server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 472
diff changeset
178
1050
146245d2198f List all bottlenecks via GET /api/bottlenecks
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1037
diff changeset
179 // Survey selection
5574
271888ef85bc Finalize use of bottleneck id instead of name.
Thomas Junk <thomas.junk@intevation.de>
parents: 5387
diff changeset
180 api.Handle("/surveys", any(&mw.JSONHandler{
812
98a7776100fb Added end point lo list available surveys for a given bottleneck.
Sascha Wilde <wilde@intevation.de>
parents: 801
diff changeset
181 Handle: listSurveys,
98a7776100fb Added end point lo list available surveys for a given bottleneck.
Sascha Wilde <wilde@intevation.de>
parents: 801
diff changeset
182 })).Methods(http.MethodGet)
98a7776100fb Added end point lo list available surveys for a given bottleneck.
Sascha Wilde <wilde@intevation.de>
parents: 801
diff changeset
183
2570
c4242b9d59fe Morphological differences: Added endpoint stub POST /api/diff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2546
diff changeset
184 // difference calculation
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
185 api.Handle("/diff", any(&mw.JSONHandler{
2570
c4242b9d59fe Morphological differences: Added endpoint stub POST /api/diff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2546
diff changeset
186 Input: func(*http.Request) interface{} { return new(models.DiffCalculationInput) },
c4242b9d59fe Morphological differences: Added endpoint stub POST /api/diff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2546
diff changeset
187 Handle: diffCalculation,
4680
976aedc195e5 Be more clever when triggering diff calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4627
diff changeset
188 NoConn: true,
2570
c4242b9d59fe Morphological differences: Added endpoint stub POST /api/diff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2546
diff changeset
189 })).Methods(http.MethodPost)
c4242b9d59fe Morphological differences: Added endpoint stub POST /api/diff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2546
diff changeset
190
633
6093016fac88 Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 486
diff changeset
191 // Cross sections
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
192 api.Handle("/cross", any(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
193 Input: func(*http.Request) interface{} { return new(models.CrossSectionInput) },
633
6093016fac88 Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 486
diff changeset
194 Handle: crossSection,
6093016fac88 Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 486
diff changeset
195 })).Methods(http.MethodPost)
6093016fac88 Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 486
diff changeset
196
743
fdff2de616ad Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents: 722
diff changeset
197 // Feature search
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
198 api.Handle("/search", any(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
199 Input: func(*http.Request) interface{} { return new(models.SearchRequest) },
743
fdff2de616ad Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents: 722
diff changeset
200 Handle: searchFeature,
fdff2de616ad Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents: 722
diff changeset
201 })).Methods(http.MethodPost)
fdff2de616ad Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents: 722
diff changeset
202
870
29c11f4bf9db Started with endpoint to upload geo style.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 846
diff changeset
203 // Geo styling
29c11f4bf9db Started with endpoint to upload geo style.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 846
diff changeset
204 api.Handle("/geo/style/{feature}",
872
b882b2c796c1 Only sys_admin should set the style of an feature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 870
diff changeset
205 sysAdmin(http.HandlerFunc(uploadStyle))).Methods(http.MethodPost)
870
29c11f4bf9db Started with endpoint to upload geo style.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 846
diff changeset
206
978
544a5cfe07cd Started with endpoint for uploading sounding result and trigger respective import job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 872
diff changeset
207 // Imports
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
208 api.Handle("/imports/sr-upload/{token}",
1228
17131f0f9fcb Added endpoint to explicitly delete a temp upload.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1224
diff changeset
209 waterwayAdmin(http.HandlerFunc(deleteSoundingUpload))).Methods(http.MethodDelete)
17131f0f9fcb Added endpoint to explicitly delete a temp upload.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1224
diff changeset
210
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
211 api.Handle("/imports/sr-upload", waterwayAdmin(&mw.JSONHandler{
1224
bc4b642c8d04 Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1192
diff changeset
212 Handle: uploadSoundingResult,
bc4b642c8d04 Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1192
diff changeset
213 })).Methods(http.MethodPost)
bc4b642c8d04 Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1192
diff changeset
214
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
215 api.Handle("/imports/sr", waterwayAdmin(
1224
bc4b642c8d04 Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1192
diff changeset
216 http.HandlerFunc(importSoundingResult))).Methods(http.MethodPost)
978
544a5cfe07cd Started with endpoint for uploading sounding result and trigger respective import job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 872
diff changeset
217
2073
e6dccc7a3ea1 Waterway profiles import: Added upload route.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2058
diff changeset
218 api.Handle("/imports/wp", waterwayAdmin(
2546
bf4a884fc306 Routing table: Removed superfluous type conversions for upload controllers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
219 importWaterwayProfiles())).Methods(http.MethodPost)
2073
e6dccc7a3ea1 Waterway profiles import: Added upload route.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2058
diff changeset
220
2256
0d272d7bcfb9 Uploaded imports: Unified agm, ubn, ufa and ugm import endpoints and removed a lot c&p code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2249
diff changeset
221 api.Handle("/imports/agm", waterwayAdmin(
2546
bf4a884fc306 Routing table: Removed superfluous type conversions for upload controllers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
222 importApprovedGaugeMeasurements())).Methods(http.MethodPost)
2256
0d272d7bcfb9 Uploaded imports: Unified agm, ubn, ufa and ugm import endpoints and removed a lot c&p code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2249
diff changeset
223
2191
4b9496752d89 Upload bottleneck import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2162
diff changeset
224 api.Handle("/imports/ubn", waterwayAdmin(
2546
bf4a884fc306 Routing table: Removed superfluous type conversions for upload controllers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
225 importUploadedBottleneck())).Methods(http.MethodPost)
2191
4b9496752d89 Upload bottleneck import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2162
diff changeset
226
2203
8d1a945d0c3b Uploaded fairway availabilty import: Implemented in terms of normal fairway availabilty import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2191
diff changeset
227 api.Handle("/imports/ufa", waterwayAdmin(
2546
bf4a884fc306 Routing table: Removed superfluous type conversions for upload controllers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
228 importUploadedFairwayAvailability())).Methods(http.MethodPost)
2203
8d1a945d0c3b Uploaded fairway availabilty import: Implemented in terms of normal fairway availabilty import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2191
diff changeset
229
2249
35db2e11c966 Uploaded gauge measurement: Implemented in terms of normal gauge measurement import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2203
diff changeset
230 api.Handle("/imports/ugm", waterwayAdmin(
2546
bf4a884fc306 Routing table: Removed superfluous type conversions for upload controllers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
231 importUploadedGaugeMeasurement())).Methods(http.MethodPost)
2249
35db2e11c966 Uploaded gauge measurement: Implemented in terms of normal gauge measurement import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2203
diff changeset
232
4311
f9bb06f2dbe3 Added stub for a shape upload stretch import. POST /api/imports/stsh
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4304
diff changeset
233 api.Handle("/imports/stsh", sysAdmin(
f9bb06f2dbe3 Added stub for a shape upload stretch import. POST /api/imports/stsh
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4304
diff changeset
234 importUploadedStretchShape())).Methods(http.MethodPost)
f9bb06f2dbe3 Added stub for a shape upload stretch import. POST /api/imports/stsh
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4304
diff changeset
235
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
236 api.Handle("/imports/{kind:st}", sysAdmin(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
237 Input: importModel,
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
238 Handle: manualImport,
1667
aaa05d3c4aac Deduplicated code for triggering manual imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1662
diff changeset
239 NoConn: true,
1662
d8ca44615bfc Implemented first version of fairway availability import.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1637
diff changeset
240 })).Methods(http.MethodPost)
d8ca44615bfc Implemented first version of fairway availability import.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1637
diff changeset
241
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
242 kinds := strings.Join([]string{
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
243 "bn", "gm", "fa", "wx", "wa",
4911
bcb8b69e4358 Type specific names for fairway marks import
Tom Gottfried <tom@intevation.de>
parents: 4894
diff changeset
244 "wg", "dmv", "fd", "dma",
4400
3b36c4d810b0 Added back end for deletion of sounding results.
Sascha Wilde <wilde@intevation.de>
parents: 4392
diff changeset
245 "sec", "dsec", "dst", "dsr",
4962
1b309a8e7673 Distinguish more clearly between BCNLAT HYDRO and IENC features
Tom Gottfried <tom@intevation.de>
parents: 4940
diff changeset
246 "fm_bcnlat_hydro",
1b309a8e7673 Distinguish more clearly between BCNLAT HYDRO and IENC features
Tom Gottfried <tom@intevation.de>
parents: 4940
diff changeset
247 "fm_bcnlat_ienc",
4913
8c1a3d5e3962 Add import for fairway marks of type BOYCAR
Tom Gottfried <tom@intevation.de>
parents: 4911
diff changeset
248 "fm_boycar",
4964
58dc06e91c39 Follow-up of rev. 1b309a8e7673 for BOYLAT
Tom Gottfried <tom@intevation.de>
parents: 4962
diff changeset
249 "fm_boylat_hydro",
58dc06e91c39 Follow-up of rev. 1b309a8e7673 for BOYLAT
Tom Gottfried <tom@intevation.de>
parents: 4962
diff changeset
250 "fm_boylat_ienc",
4940
b3b2ba09a450 Add missing fairway mark types
Tom Gottfried <tom@intevation.de>
parents: 4922
diff changeset
251 "fm_boysaw",
b3b2ba09a450 Add missing fairway mark types
Tom Gottfried <tom@intevation.de>
parents: 4922
diff changeset
252 "fm_boyspp",
4967
3f704ebad0c5 Follow-up of rev. 1b309a8e7673 for DAYMAR
Tom Gottfried <tom@intevation.de>
parents: 4964
diff changeset
253 "fm_daymar_hydro",
3f704ebad0c5 Follow-up of rev. 1b309a8e7673 for DAYMAR
Tom Gottfried <tom@intevation.de>
parents: 4964
diff changeset
254 "fm_daymar_ienc",
4940
b3b2ba09a450 Add missing fairway mark types
Tom Gottfried <tom@intevation.de>
parents: 4922
diff changeset
255 "fm_lights",
b3b2ba09a450 Add missing fairway mark types
Tom Gottfried <tom@intevation.de>
parents: 4922
diff changeset
256 "fm_rtpbcn",
b3b2ba09a450 Add missing fairway mark types
Tom Gottfried <tom@intevation.de>
parents: 4922
diff changeset
257 "fm_topmar",
b3b2ba09a450 Add missing fairway mark types
Tom Gottfried <tom@intevation.de>
parents: 4922
diff changeset
258 "fm_notmrk",
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
259 }, "|")
1808
77582da3adb0 Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1785
diff changeset
260
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
261 api.Handle("/imports/{kind:"+kinds+"}", waterwayAdmin(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
262 Input: importModel,
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
263 Handle: manualImport,
1901
71b722809b2b Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1862
diff changeset
264 NoConn: true,
71b722809b2b Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1862
diff changeset
265 })).Methods(http.MethodPost)
71b722809b2b Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1862
diff changeset
266
5387
8e30b926b94d Added an import to run update stats scripts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5386
diff changeset
267 api.Handle("/imports/{kind:report|statsupdate}", sysAdmin(&mw.JSONHandler{
5366
cb46f50ba168 Allow /api/imports/report only to sysadmins.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5345
diff changeset
268 Input: importModel,
cb46f50ba168 Allow /api/imports/report only to sysadmins.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5345
diff changeset
269 Handle: manualImport,
cb46f50ba168 Allow /api/imports/report only to sysadmins.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5345
diff changeset
270 NoConn: true,
cb46f50ba168 Allow /api/imports/report only to sysadmins.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5345
diff changeset
271 })).Methods(http.MethodPost)
cb46f50ba168 Allow /api/imports/report only to sysadmins.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5345
diff changeset
272
1583
caedd9b176f2 Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1582
diff changeset
273 // Import scheduler configuration
1730
7c54babe10f7 Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1693
diff changeset
274 api.Handle("/imports/config/{id:[0-9]+}/run",
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
275 waterwayAdmin(&mw.JSONHandler{
1730
7c54babe10f7 Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1693
diff changeset
276 Handle: runImportConfig,
7c54babe10f7 Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1693
diff changeset
277 })).Methods(http.MethodGet)
7c54babe10f7 Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1693
diff changeset
278
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
279 api.Handle("/imports/config/{id:[0-9]+}",
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
280 waterwayAdmin(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
281 Input: func(*http.Request) interface{} { return &json.RawMessage{} },
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
282 Handle: modifyImportConfig,
1592
c12cec1d7692 Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1591
diff changeset
283 })).Methods(http.MethodPatch)
c12cec1d7692 Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1591
diff changeset
284
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
285 api.Handle("/imports/config/{id:[0-9]+}",
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
286 waterwayAdmin(&mw.JSONHandler{
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
287 Handle: deleteImportConfig,
1590
2fdd8e57542d Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1589
diff changeset
288 })).Methods(http.MethodDelete)
2fdd8e57542d Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1589
diff changeset
289
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
290 api.Handle("/imports/config/{id:[0-9]+}",
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
291 waterwayAdmin(&mw.JSONHandler{
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
292 Handle: infoImportConfig,
1591
2d53065c95af Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1590
diff changeset
293 })).Methods(http.MethodGet)
2d53065c95af Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1590
diff changeset
294
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
295 api.Handle("/imports/config",
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
296 waterwayAdmin(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
297 Input: func(*http.Request) interface{} { return new(imports.ImportConfigIn) },
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
298 Handle: addImportConfig,
1589
e0bd82f6ee14 Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1583
diff changeset
299 })).Methods(http.MethodPost)
e0bd82f6ee14 Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1583
diff changeset
300
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
301 api.Handle("/imports/config",
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
302 waterwayAdmin(&mw.JSONHandler{
1627
b10aa02d7819 Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1592
diff changeset
303 Handle: listImportConfigs,
1583
caedd9b176f2 Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1582
diff changeset
304 })).Methods(http.MethodGet)
caedd9b176f2 Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1582
diff changeset
305
1023
337a7f4c8a16 Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1017
diff changeset
306 // Import queue
4790
6f3730196ebb endpoint routing: get rid of unnecessary local variable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4747
diff changeset
307
6f3730196ebb endpoint routing: get rid of unnecessary local variable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4747
diff changeset
308 api.Handle("/imports", waterwayAdmin(&mw.JSONHandler{
1023
337a7f4c8a16 Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1017
diff changeset
309 Handle: listImports,
4790
6f3730196ebb endpoint routing: get rid of unnecessary local variable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4747
diff changeset
310 })).Methods(http.MethodGet)
1023
337a7f4c8a16 Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1017
diff changeset
311
4800
37429e50a74f Allow import log export for waterwayAdmin.
Sascha Wilde <wilde@intevation.de>
parents: 4791
diff changeset
312 api.Handle("/imports/export", waterwayAdmin(
4791
1fef4679b07a Added an endpoint GET api/imports/export to export imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4790
diff changeset
313 mw.DBConn(http.HandlerFunc(exportImports)))).Methods(http.MethodGet)
1fef4679b07a Added an endpoint GET api/imports/export to export imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4790
diff changeset
314
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
315 api.Handle("/imports/{id:[0-9]+}", waterwayAdmin(&mw.JSONHandler{
1026
3de54d7b7d30 Added endpoint to show the detail logs of an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1023
diff changeset
316 Handle: importLogs,
1037
a04126989d91 Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1026
diff changeset
317 })).Methods(http.MethodGet)
a04126989d91 Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1026
diff changeset
318
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
319 api.Handle("/imports", waterwayAdmin(&mw.JSONHandler{
2058
09f9ae3d0526 Imports: Handle manual imports with a single route using the shortnames of the imports to distiquish between them.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
320 Input: func(*http.Request) interface{} { return &[]models.Review{} },
1468
5e1218b5a123 proof of concept
Thomas Junk <thomas.junk@intevation.de>
parents: 1315
diff changeset
321 Handle: reviewImports,
5028
d727641911a5 Moved import desision logic to import queue (where it belongs).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4967
diff changeset
322 NoConn: true,
1468
5e1218b5a123 proof of concept
Thomas Junk <thomas.junk@intevation.de>
parents: 1315
diff changeset
323 })).Methods(http.MethodPatch)
5e1218b5a123 proof of concept
Thomas Junk <thomas.junk@intevation.de>
parents: 1315
diff changeset
324
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
325 api.Handle("/imports/{id:[0-9]+}", waterwayAdmin(&mw.JSONHandler{
1037
a04126989d91 Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1026
diff changeset
326 Handle: deleteImport,
a04126989d91 Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1026
diff changeset
327 })).Methods(http.MethodDelete)
1026
3de54d7b7d30 Added endpoint to show the detail logs of an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1023
diff changeset
328
1192
3afa71405b87 Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1189
diff changeset
329 // Handler to review an import which is pending.
3afa71405b87 Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1189
diff changeset
330 api.Handle("/imports/{id:[0-9]+}/{state:(?:accepted|declined)}",
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
331 waterwayAdmin(&mw.JSONHandler{
1192
3afa71405b87 Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1189
diff changeset
332 Handle: reviewImport,
5028
d727641911a5 Moved import desision logic to import queue (where it belongs).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4967
diff changeset
333 NoConn: true,
1192
3afa71405b87 Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1189
diff changeset
334 })).Methods(http.MethodPut)
3afa71405b87 Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1189
diff changeset
335
5321
0919946f624b Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5237
diff changeset
336 // Handler for reporting
0919946f624b Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5237
diff changeset
337
5324
348d91848278 Added and endpoint GET /api/data/reports to list the available report templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5321
diff changeset
338 api.Handle("/data/reports",
348d91848278 Added and endpoint GET /api/data/reports to list the available report templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5321
diff changeset
339 waterwayAdmin(&mw.JSONHandler{
348d91848278 Added and endpoint GET /api/data/reports to list the available report templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5321
diff changeset
340 Handle: listReports,
348d91848278 Added and endpoint GET /api/data/reports to list the available report templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5321
diff changeset
341 NoConn: true,
348d91848278 Added and endpoint GET /api/data/reports to list the available report templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5321
diff changeset
342 })).Methods(http.MethodGet)
348d91848278 Added and endpoint GET /api/data/reports to list the available report templates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5321
diff changeset
343
5377
d19fdf3d2099 Add a string type that allows only runes that are safe of directory traversal.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5375
diff changeset
344 api.Handle("/data/report/{name:"+models.SafePathExp+"}", waterwayAdmin(
5321
0919946f624b Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5237
diff changeset
345 mw.DBConn(http.HandlerFunc(report)))).Methods(http.MethodGet)
0919946f624b Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5237
diff changeset
346
5386
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
347 // Handler for update scripts
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
348 api.Handle("/data/stats-updates",
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
349 sysAdmin(&mw.JSONHandler{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
350 Handle: listStatsUpdates,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
351 })).Methods(http.MethodGet)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
352
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
353 api.Handle("/data/stats-updates/{name:.+}",
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
354 sysAdmin(&mw.JSONHandler{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
355 Handle: statsUpdates,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
356 })).Methods(http.MethodGet)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5377
diff changeset
357
2694
0d7a4fdb9e12 Added GET /api/data/waterlevels/{gauge isrs}?from={time_a}&to={time_b} to fetch waterlevels of gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2570
diff changeset
358 // Handler to serve data to the client.
0d7a4fdb9e12 Added GET /api/data/waterlevels/{gauge isrs}?from={time_a}&to={time_b} to fetch waterlevels of gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2570
diff changeset
359
5237
6ba7e6ac0882 Switched kind and type parts in route.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5218
diff changeset
360 api.Handle("/data/{type:availability|fairway}/{kind:stretch|section|bottleneck}/{name:.+}", any(
5184
445daeefca7b Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5028
diff changeset
361 mw.DBConn(http.HandlerFunc(fairwayAvailability)))).Methods(http.MethodGet)
445daeefca7b Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 5028
diff changeset
362
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
363 api.Handle("/data/stretch/shape/{name:.+}", any(
4296
95786a675d70 WIP: Started with downloading stretches as ESRI shapes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4244
diff changeset
364 mw.DBConn(http.HandlerFunc(stretchShapeDownload)))).Methods(http.MethodGet)
95786a675d70 WIP: Started with downloading stretches as ESRI shapes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4244
diff changeset
365
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
366 api.Handle("/data/waterlevels/{gauge:.+}", any(
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
367 mw.DBConn(http.HandlerFunc(waterlevels)))).Methods(http.MethodGet)
2694
0d7a4fdb9e12 Added GET /api/data/waterlevels/{gauge isrs}?from={time_a}&to={time_b} to fetch waterlevels of gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2570
diff changeset
368
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
369 api.Handle("/data/longterm-waterlevels/{gauge:.+}", any(
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
370 mw.DBConn(http.HandlerFunc(longtermWaterlevels)))).Methods(http.MethodGet)
2800
db1052bc162a Added GET /data/longterm-waterlevels/{gauge}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2762
diff changeset
371
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
372 // TODO: gauge should not contain '/'s.
2803
46a9a7c1281f Added GET /api/data/year-waterlevels/{gauge}/{year}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2800
diff changeset
373 api.Handle("/data/year-waterlevels/{gauge}/{year:[0-9]+}", any(
4244
4394daeea96a Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4236
diff changeset
374 mw.DBConn(http.HandlerFunc(yearWaterlevels)))).Methods(http.MethodGet)
2803
46a9a7c1281f Added GET /api/data/year-waterlevels/{gauge}/{year}
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2800
diff changeset
375
4627
8f38a1bb9b79 Applied {name:.+} workarounds in routing where applicable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4400
diff changeset
376 api.Handle("/data/nash-sutcliffe/{gauge:.+}", any(&mw.JSONHandler{
2741
87aed4f9b1b8 Added calculation of Nash Sutcliffe efficiency coefficents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2694
diff changeset
377 Handle: nashSutcliffe,
87aed4f9b1b8 Added calculation of Nash Sutcliffe efficiency coefficents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2694
diff changeset
378 })).Methods(http.MethodGet)
87aed4f9b1b8 Added calculation of Nash Sutcliffe efficiency coefficents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2694
diff changeset
379
335
bd292a554b6e Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 304
diff changeset
380 // Token handling: Login/Logout.
231
694f959ba3e7 Fixed bad route to /logout controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 226
diff changeset
381 api.HandleFunc("/login", login).
484
2ac37419f593 Implemented wamos/issue114 (Improve code consistency: For login use json body, disallow GET).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 474
diff changeset
382 Methods(http.MethodPost)
231
694f959ba3e7 Fixed bad route to /logout controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 226
diff changeset
383 api.Handle("/logout", auth.SessionMiddleware(http.HandlerFunc(logout))).
226
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
384 Methods(http.MethodGet, http.MethodPost)
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
385 api.Handle("/renew", auth.SessionMiddleware(http.HandlerFunc(renew))).
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
386 Methods(http.MethodGet, http.MethodPost)
63dd5216eee4 Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
387 }