Mercurial > gemma
annotate pkg/controllers/routes.go @ 2006:35acb7f9ae0c
Do anything else before expectedly failing role creation
Creating roles during database setup expectedly fails in case there
already is another gemma database in the cluster. Doing it at the end
of the transaction ensures it does not hide errors in other commands
in the script.
In passing, add the default admin via the designated view to ensure it
will become a correctly set up application user.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 24 Jan 2019 17:23:43 +0100 |
parents | 71b722809b2b |
children | 42a33f9e1f95 |
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 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
978
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
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 ( |
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 "net/http" |
346
ad0e47c1fedf
Use httputil.ReverseProxy for WFS proxying.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
19 "net/http/httputil" |
226
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
414
c1047fd04a3a
Moved project specific Go packages to new pkg folder.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
408
diff
changeset
|
21 "github.com/gorilla/mux" |
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 "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
|
24 "gemma.intevation.de/gemma/pkg/imports" |
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
|
25 "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
|
26 "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
|
27 ) |
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
1693
cdc8933949f2
Controllers: Resolved the remaining golint issues with this package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1677
diff
changeset
|
29 // 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
|
30 func BindRoutes(m *mux.Router) { |
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 api := m.PathPrefix("/api").Subrouter() |
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
270
d1b0d964af09
Dont restrict listing/updating of users to sys_admins.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
254
diff
changeset
|
34 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
|
35 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
|
36 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
|
37 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
|
38 ) |
226
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
335
bd292a554b6e
Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
304
diff
changeset
|
40 // User management. |
472
39b5deee8810
Replaced 'all' by 'any' in routes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
41 api.Handle("/users", any(&JSONHandler{ |
250
deabc2712634
Implemented /users GET as list of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
242
diff
changeset
|
42 Handle: listUsers, |
deabc2712634
Implemented /users GET as list of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
242
diff
changeset
|
43 })).Methods(http.MethodGet) |
deabc2712634
Implemented /users GET as list of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
242
diff
changeset
|
44 |
deabc2712634
Implemented /users GET as list of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
242
diff
changeset
|
45 api.Handle("/users", sysAdmin(&JSONHandler{ |
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
|
46 Input: func() 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
|
47 Handle: createUser, |
237
3771788d3dae
Reduce boilerplate code when writing JSON parsing/generating endpoints.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
235
diff
changeset
|
48 })).Methods(http.MethodPost) |
3771788d3dae
Reduce boilerplate code when writing JSON parsing/generating endpoints.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
235
diff
changeset
|
49 |
472
39b5deee8810
Replaced 'all' by 'any' in routes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
50 api.Handle("/users/{user}", any(&JSONHandler{ |
254
de6fdb316b8f
Implemented /users/{user} GET a listing of given user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
250
diff
changeset
|
51 Handle: listUser, |
de6fdb316b8f
Implemented /users/{user} GET a listing of given user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
250
diff
changeset
|
52 })).Methods(http.MethodGet) |
de6fdb316b8f
Implemented /users/{user} GET a listing of given user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
250
diff
changeset
|
53 |
472
39b5deee8810
Replaced 'all' by 'any' in routes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
54 api.Handle("/users/{user}", any(&JSONHandler{ |
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
|
55 Input: func() 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
|
56 Handle: updateUser, |
237
3771788d3dae
Reduce boilerplate code when writing JSON parsing/generating endpoints.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
235
diff
changeset
|
57 })).Methods(http.MethodPut) |
226
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
240
9012e4045da4
Implemented /user delete controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
239
diff
changeset
|
59 api.Handle("/users/{user}", sysAdmin(&JSONHandler{ |
9012e4045da4
Implemented /user delete controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
239
diff
changeset
|
60 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
|
61 })).Methods(http.MethodDelete) |
240
9012e4045da4
Implemented /user delete controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
239
diff
changeset
|
62 |
822
8926c413db21
Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents:
812
diff
changeset
|
63 // System notifications |
8926c413db21
Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents:
812
diff
changeset
|
64 api.Handle("/testmail/{user}", sysAdmin(&JSONHandler{ |
8926c413db21
Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents:
812
diff
changeset
|
65 Handle: sendTestMail, |
8926c413db21
Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents:
812
diff
changeset
|
66 })).Methods(http.MethodGet) |
8926c413db21
Started implementation of test mail end point.
Sascha Wilde <wilde@intevation.de>
parents:
812
diff
changeset
|
67 |
722
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
710
diff
changeset
|
68 // System Management |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
710
diff
changeset
|
69 api.Handle("/system/log/{service}/{file}", sysAdmin(&JSONHandler{ |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
710
diff
changeset
|
70 Handle: showSystemLog, |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
710
diff
changeset
|
71 NoConn: true, |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
710
diff
changeset
|
72 })).Methods(http.MethodGet) |
815f5e2ed974
Added simple endpoint to view system logs.
Sascha Wilde <wilde@intevation.de>
parents:
710
diff
changeset
|
73 |
840
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
822
diff
changeset
|
74 // System Settings |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
822
diff
changeset
|
75 api.Handle("/system/style/{feature}/{attr}", any(&JSONHandler{ |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
822
diff
changeset
|
76 Handle: getFeatureStyle, |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
822
diff
changeset
|
77 })).Methods(http.MethodGet) |
0f61bfc21041
Added end point to get style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
822
diff
changeset
|
78 |
846
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
79 api.Handle("/system/style/{feature}/{attr}", any(&JSONHandler{ |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
80 Input: func() interface{} { return new(models.Colour) }, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
81 Handle: setFeatureStyle, |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
82 })).Methods(http.MethodPut) |
6902032757e4
Added end point to set style (colour) information for feature.
Sascha Wilde <wilde@intevation.de>
parents:
840
diff
changeset
|
83 |
335
bd292a554b6e
Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
304
diff
changeset
|
84 // Password resets. |
302
0777aa6de45b
Password reset. Part I
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
281
diff
changeset
|
85 api.Handle("/users/passwordreset", &JSONHandler{ |
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
|
86 Input: func() interface{} { return new(models.PWResetUser) }, |
304
69e291f26bbd
Password reset: Part II.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
302
diff
changeset
|
87 Handle: passwordResetRequest, |
710
3e9f0070c33e
Password reset endpoints do not need impersonated db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
88 NoConn: true, |
304
69e291f26bbd
Password reset: Part II.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
302
diff
changeset
|
89 }).Methods(http.MethodPost) |
69e291f26bbd
Password reset: Part II.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
302
diff
changeset
|
90 |
69e291f26bbd
Password reset: Part II.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
302
diff
changeset
|
91 api.Handle("/users/passwordreset/{hash}", &JSONHandler{ |
302
0777aa6de45b
Password reset. Part I
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
281
diff
changeset
|
92 Handle: passwordReset, |
710
3e9f0070c33e
Password reset endpoints do not need impersonated db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
93 NoConn: true, |
304
69e291f26bbd
Password reset: Part II.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
302
diff
changeset
|
94 }).Methods(http.MethodGet) |
302
0777aa6de45b
Password reset. Part I
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
281
diff
changeset
|
95 |
426
4a03d000c854
Fixed wrong comments.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
421
diff
changeset
|
96 // External proxies. |
1127
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1051
diff
changeset
|
97 external := middleware.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
|
98 Director: proxyDirector(models.ExternalServices.Find), |
421
c37457f12b8e
Differ between internal and external proxies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
419
diff
changeset
|
99 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
|
100 }) |
346
ad0e47c1fedf
Use httputil.ReverseProxy for WFS proxying.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
101 |
472
39b5deee8810
Replaced 'all' by 'any' in routes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
102 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
|
103 |
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
|
104 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
|
105 Methods( |
ac23905e64b1
Improve WFS proxy a lot. It now generates signed re-writings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
359
diff
changeset
|
106 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
|
107 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
|
108 |
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
|
109 api.Handle("/external/{entry}", externalAuth). |
335
bd292a554b6e
Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
304
diff
changeset
|
110 Methods( |
bd292a554b6e
Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
304
diff
changeset
|
111 http.MethodGet, http.MethodPost, |
bd292a554b6e
Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
304
diff
changeset
|
112 http.MethodPut, http.MethodDelete) |
bd292a554b6e
Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
304
diff
changeset
|
113 |
426
4a03d000c854
Fixed wrong comments.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
421
diff
changeset
|
114 // Internal proxies. |
1127
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1051
diff
changeset
|
115 internal := middleware.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
|
116 Director: proxyDirector(models.InternalServices.Find), |
421
c37457f12b8e
Differ between internal and external proxies.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
419
diff
changeset
|
117 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
|
118 }) |
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
|
119 |
472
39b5deee8810
Replaced 'all' by 'any' in routes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
120 internalAuth := any( |
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
|
121 middleware.ModifyQuery(internal, middleware.InjectUser)) |
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
|
122 |
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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 |
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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 |
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
|
133 api.Handle("/published", any(&JSONHandler{ |
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
|
134 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
|
135 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
|
136 })).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
|
137 |
1050
146245d2198f
List all bottlenecks via GET /api/bottlenecks
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1037
diff
changeset
|
138 // Survey selection |
812
98a7776100fb
Added end point lo list available surveys for a given bottleneck.
Sascha Wilde <wilde@intevation.de>
parents:
801
diff
changeset
|
139 api.Handle("/surveys/{bottleneck}", any(&JSONHandler{ |
98a7776100fb
Added end point lo list available surveys for a given bottleneck.
Sascha Wilde <wilde@intevation.de>
parents:
801
diff
changeset
|
140 Handle: listSurveys, |
98a7776100fb
Added end point lo list available surveys for a given bottleneck.
Sascha Wilde <wilde@intevation.de>
parents:
801
diff
changeset
|
141 })).Methods(http.MethodGet) |
98a7776100fb
Added end point lo list available surveys for a given bottleneck.
Sascha Wilde <wilde@intevation.de>
parents:
801
diff
changeset
|
142 |
1050
146245d2198f
List all bottlenecks via GET /api/bottlenecks
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1037
diff
changeset
|
143 // Bottlenecks |
1051
137a8144e581
Typo fix.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1050
diff
changeset
|
144 api.Handle("/bottlenecks", any(&JSONHandler{ |
1050
146245d2198f
List all bottlenecks via GET /api/bottlenecks
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1037
diff
changeset
|
145 Handle: listBottlenecks, |
146245d2198f
List all bottlenecks via GET /api/bottlenecks
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1037
diff
changeset
|
146 })).Methods(http.MethodGet) |
146245d2198f
List all bottlenecks via GET /api/bottlenecks
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1037
diff
changeset
|
147 |
633
6093016fac88
Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
486
diff
changeset
|
148 // Cross sections |
642
e95df6657023
Cross sections: call web endpoint simply 'cross' instead of 'cross-section'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
149 api.Handle("/cross", any(&JSONHandler{ |
633
6093016fac88
Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
486
diff
changeset
|
150 Input: func() interface{} { return new(models.CrossSectionInput) }, |
6093016fac88
Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
486
diff
changeset
|
151 Handle: crossSection, |
6093016fac88
Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
486
diff
changeset
|
152 })).Methods(http.MethodPost) |
6093016fac88
Cross sections: started with implementation of web service (WIP).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
486
diff
changeset
|
153 |
743
fdff2de616ad
Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
154 // Feature search |
fdff2de616ad
Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
155 api.Handle("/search", any(&JSONHandler{ |
fdff2de616ad
Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
156 Input: func() interface{} { return new(models.SearchRequest) }, |
fdff2de616ad
Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
157 Handle: searchFeature, |
fdff2de616ad
Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
158 })).Methods(http.MethodPost) |
fdff2de616ad
Added search function for river kilometer.
Sascha Wilde <wilde@intevation.de>
parents:
722
diff
changeset
|
159 |
870
29c11f4bf9db
Started with endpoint to upload geo style.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
846
diff
changeset
|
160 // Geo styling |
29c11f4bf9db
Started with endpoint to upload geo style.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
846
diff
changeset
|
161 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
|
162 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
|
163 |
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
|
164 // Imports |
1228
17131f0f9fcb
Added endpoint to explicitly delete a temp upload.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1224
diff
changeset
|
165 api.Handle("/imports/soundingresult-upload/{token}", |
17131f0f9fcb
Added endpoint to explicitly delete a temp upload.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1224
diff
changeset
|
166 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
|
167 |
1224
bc4b642c8d04
Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1192
diff
changeset
|
168 api.Handle("/imports/soundingresult-upload", waterwayAdmin(&JSONHandler{ |
bc4b642c8d04
Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1192
diff
changeset
|
169 Handle: uploadSoundingResult, |
bc4b642c8d04
Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1192
diff
changeset
|
170 })).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
|
171 |
bc4b642c8d04
Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1192
diff
changeset
|
172 api.Handle("/imports/soundingresult", waterwayAdmin( |
bc4b642c8d04
Started with an upload sounding result to temp upload area.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1192
diff
changeset
|
173 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
|
174 |
1741
44398a8bdf94
Approved gauge measurements: Added a stub to upload a CSV file for parsing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1732
diff
changeset
|
175 api.Handle("/imports/approvedgm", waterwayAdmin( |
44398a8bdf94
Approved gauge measurements: Added a stub to upload a CSV file for parsing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1732
diff
changeset
|
176 http.HandlerFunc(importApprovedGaugeMeasurements))).Methods(http.MethodPost) |
44398a8bdf94
Approved gauge measurements: Added a stub to upload a CSV file for parsing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1732
diff
changeset
|
177 |
1534
165f31b71042
Bottleneck import: Added /api/imports/bottleneck POST endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1473
diff
changeset
|
178 api.Handle("/imports/bottleneck", waterwayAdmin(&JSONHandler{ |
165f31b71042
Bottleneck import: Added /api/imports/bottleneck POST endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1473
diff
changeset
|
179 Input: func() interface{} { return new(models.BottleneckImport) }, |
1667
aaa05d3c4aac
Deduplicated code for triggering manual imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
180 Handle: manualImport(imports.BNJobKind, importBottleneck), |
aaa05d3c4aac
Deduplicated code for triggering manual imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
181 NoConn: true, |
1534
165f31b71042
Bottleneck import: Added /api/imports/bottleneck POST endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1473
diff
changeset
|
182 })).Methods(http.MethodPost) |
165f31b71042
Bottleneck import: Added /api/imports/bottleneck POST endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1473
diff
changeset
|
183 |
1637
dd31be75ce6d
Implemented gauge measurement import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1627
diff
changeset
|
184 api.Handle("/imports/gaugemeasurement", waterwayAdmin(&JSONHandler{ |
dd31be75ce6d
Implemented gauge measurement import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1627
diff
changeset
|
185 Input: func() interface{} { return new(models.GaugeMeasurementImport) }, |
1667
aaa05d3c4aac
Deduplicated code for triggering manual imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
186 Handle: manualImport(imports.GMJobKind, importGaugeMeasurement), |
aaa05d3c4aac
Deduplicated code for triggering manual imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
187 NoConn: true, |
1637
dd31be75ce6d
Implemented gauge measurement import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1627
diff
changeset
|
188 })).Methods(http.MethodPost) |
dd31be75ce6d
Implemented gauge measurement import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1627
diff
changeset
|
189 |
1662
d8ca44615bfc
Implemented first version of fairway availability import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1637
diff
changeset
|
190 api.Handle("/imports/fairwayavailability", waterwayAdmin(&JSONHandler{ |
d8ca44615bfc
Implemented first version of fairway availability import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1637
diff
changeset
|
191 Input: func() interface{} { return new(models.FairwayAvailabilityImport) }, |
1667
aaa05d3c4aac
Deduplicated code for triggering manual imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
192 Handle: manualImport(imports.FAJobKind, importFairwayAvailability), |
aaa05d3c4aac
Deduplicated code for triggering manual imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1662
diff
changeset
|
193 NoConn: true, |
1662
d8ca44615bfc
Implemented first version of fairway availability import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1637
diff
changeset
|
194 })).Methods(http.MethodPost) |
d8ca44615bfc
Implemented first version of fairway availability import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1637
diff
changeset
|
195 |
1677
53304db85888
Waterway axis import: Added route for manual import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1667
diff
changeset
|
196 api.Handle("/imports/waterwayaxis", waterwayAdmin(&JSONHandler{ |
53304db85888
Waterway axis import: Added route for manual import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1667
diff
changeset
|
197 Input: func() interface{} { return new(models.WaterwayAxisImport) }, |
53304db85888
Waterway axis import: Added route for manual import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1667
diff
changeset
|
198 Handle: manualImport(imports.WXJobKind, importWaterwayAxis), |
53304db85888
Waterway axis import: Added route for manual import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1667
diff
changeset
|
199 NoConn: true, |
53304db85888
Waterway axis import: Added route for manual import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1667
diff
changeset
|
200 })).Methods(http.MethodPost) |
53304db85888
Waterway axis import: Added route for manual import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1667
diff
changeset
|
201 |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1748
diff
changeset
|
202 api.Handle("/imports/waterwayarea", waterwayAdmin(&JSONHandler{ |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1748
diff
changeset
|
203 Input: func() interface{} { return new(models.WaterwayAreaImport) }, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1748
diff
changeset
|
204 Handle: manualImport(imports.WAJobKind, importWaterwayArea), |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1748
diff
changeset
|
205 NoConn: true, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1748
diff
changeset
|
206 })).Methods(http.MethodPost) |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1748
diff
changeset
|
207 |
1808
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
208 api.Handle("/imports/waterwaygauge", waterwayAdmin(&JSONHandler{ |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
209 Input: func() interface{} { return new(models.WaterwayGaugeImport) }, |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
210 Handle: manualImport(imports.WGJobKind, importWaterwayGauge), |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
211 NoConn: true, |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
212 })).Methods(http.MethodPost) |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
213 |
1855
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1841
diff
changeset
|
214 api.Handle("/imports/distancemarksvirtual", waterwayAdmin(&JSONHandler{ |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1841
diff
changeset
|
215 Input: func() interface{} { return new(models.DistanceMarksVirtualImport) }, |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1841
diff
changeset
|
216 Handle: manualImport(imports.DMVJobKind, importDistancemarksVirtual), |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1841
diff
changeset
|
217 NoConn: true, |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1841
diff
changeset
|
218 })).Methods(http.MethodPost) |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1841
diff
changeset
|
219 |
1841
491f5b68da9e
Implemented fairway dimension import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1808
diff
changeset
|
220 api.Handle("/imports/fairwaydimension", waterwayAdmin(&JSONHandler{ |
491f5b68da9e
Implemented fairway dimension import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1808
diff
changeset
|
221 Input: func() interface{} { return new(models.FairwayDimensionImport) }, |
491f5b68da9e
Implemented fairway dimension import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1808
diff
changeset
|
222 Handle: manualImport(imports.FDJobKind, importFairwayDimension), |
491f5b68da9e
Implemented fairway dimension import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1808
diff
changeset
|
223 NoConn: true, |
491f5b68da9e
Implemented fairway dimension import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1808
diff
changeset
|
224 })).Methods(http.MethodPost) |
491f5b68da9e
Implemented fairway dimension import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1808
diff
changeset
|
225 |
1862
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1855
diff
changeset
|
226 api.Handle("/imports/distancemarks", waterwayAdmin(&JSONHandler{ |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1855
diff
changeset
|
227 Input: func() interface{} { return new(models.DistanceMarksAshoreImport) }, |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1855
diff
changeset
|
228 Handle: manualImport(imports.DMAJobKind, importDistanceMarksAshore), |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1855
diff
changeset
|
229 NoConn: true, |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1855
diff
changeset
|
230 })).Methods(http.MethodPost) |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1855
diff
changeset
|
231 |
1901
71b722809b2b
Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1862
diff
changeset
|
232 api.Handle("/imports/stretch", sysAdmin(&JSONHandler{ |
71b722809b2b
Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1862
diff
changeset
|
233 Input: func() interface{} { return new(models.StretchImport) }, |
71b722809b2b
Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1862
diff
changeset
|
234 Handle: manualImport(imports.STJobKind, importStretch), |
71b722809b2b
Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1862
diff
changeset
|
235 NoConn: true, |
71b722809b2b
Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1862
diff
changeset
|
236 })).Methods(http.MethodPost) |
71b722809b2b
Stretch import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1862
diff
changeset
|
237 |
1583
caedd9b176f2
Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1582
diff
changeset
|
238 // 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
|
239 api.Handle("/imports/config/{id:[0-9]+}/run", |
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
|
240 waterwayAdmin(&JSONHandler{ |
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
|
241 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
|
242 })).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
|
243 |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
244 api.Handle("/imports/config/{id:[0-9]+}", |
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
|
245 waterwayAdmin(&JSONHandler{ |
1732
73aab5f9a934
Import configuration: Modification endpoint needs an inpit document.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1730
diff
changeset
|
246 Input: func() interface{} { return new(imports.Config) }, |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
247 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
|
248 })).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
|
249 |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
250 api.Handle("/imports/config/{id:[0-9]+}", |
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
|
251 waterwayAdmin(&JSONHandler{ |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
252 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
|
253 })).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
|
254 |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
255 api.Handle("/imports/config/{id:[0-9]+}", |
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
|
256 waterwayAdmin(&JSONHandler{ |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
257 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
|
258 })).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
|
259 |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
260 api.Handle("/imports/config", |
1583
caedd9b176f2
Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1582
diff
changeset
|
261 waterwayAdmin(&JSONHandler{ |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
262 Input: func() interface{} { return new(imports.Config) }, |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
263 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
|
264 })).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
|
265 |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
266 api.Handle("/imports/config", |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
267 waterwayAdmin(&JSONHandler{ |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1592
diff
changeset
|
268 Handle: listImportConfigs, |
1583
caedd9b176f2
Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1582
diff
changeset
|
269 })).Methods(http.MethodGet) |
caedd9b176f2
Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1582
diff
changeset
|
270 |
1023
337a7f4c8a16
Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
271 // Import queue |
337a7f4c8a16
Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
272 lsImports := waterwayAdmin(&JSONHandler{ |
337a7f4c8a16
Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
273 Handle: listImports, |
337a7f4c8a16
Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
274 }) |
337a7f4c8a16
Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
275 |
337a7f4c8a16
Add endpoint to list all or some import jobs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
276 api.Handle("/imports", lsImports). |
1315
24e4c60c2606
Simplified and fixed filtering of import queue listing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1228
diff
changeset
|
277 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
|
278 |
1026
3de54d7b7d30
Added endpoint to show the detail logs of an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1023
diff
changeset
|
279 api.Handle("/imports/{id:[0-9]+}", waterwayAdmin(&JSONHandler{ |
3de54d7b7d30
Added endpoint to show the detail logs of an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1023
diff
changeset
|
280 Handle: importLogs, |
1037
a04126989d91
Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1026
diff
changeset
|
281 })).Methods(http.MethodGet) |
a04126989d91
Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1026
diff
changeset
|
282 |
1468 | 283 api.Handle("/imports", waterwayAdmin(&JSONHandler{ |
1473
d349618c6b50
Import bulk review: Fixed handling of input document.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1472
diff
changeset
|
284 Input: func() interface{} { return &[]models.Review{} }, |
1468 | 285 Handle: reviewImports, |
286 })).Methods(http.MethodPatch) | |
287 | |
1037
a04126989d91
Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1026
diff
changeset
|
288 api.Handle("/imports/{id:[0-9]+}", waterwayAdmin(&JSONHandler{ |
a04126989d91
Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1026
diff
changeset
|
289 Handle: deleteImport, |
a04126989d91
Added endpoint to delete job from import queue.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1026
diff
changeset
|
290 })).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
|
291 |
1192
3afa71405b87
Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1189
diff
changeset
|
292 // 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
|
293 api.Handle("/imports/{id:[0-9]+}/{state:(?:accepted|declined)}", |
3afa71405b87
Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1189
diff
changeset
|
294 waterwayAdmin(&JSONHandler{ |
3afa71405b87
Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1189
diff
changeset
|
295 Handle: reviewImport, |
3afa71405b87
Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1189
diff
changeset
|
296 })).Methods(http.MethodPut) |
3afa71405b87
Added REST endpoint to accept or decline an import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1189
diff
changeset
|
297 |
335
bd292a554b6e
Made gemma a WFS proxy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
304
diff
changeset
|
298 // Token handling: Login/Logout. |
231
694f959ba3e7
Fixed bad route to /logout controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
226
diff
changeset
|
299 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
|
300 Methods(http.MethodPost) |
231
694f959ba3e7
Fixed bad route to /logout controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
226
diff
changeset
|
301 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
|
302 Methods(http.MethodGet, http.MethodPost) |
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
303 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
|
304 Methods(http.MethodGet, http.MethodPost) |
63dd5216eee4
Refactored gemma server to be more REST-like.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
305 } |