Mercurial > gemma
comparison pkg/controllers/routes.go @ 4627:8f38a1bb9b79
Applied {name:.+} workarounds in routing where applicable.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 10 Oct 2019 16:13:11 +0200 |
parents | 3b36c4d810b0 |
children | 976aedc195e5 |
comparison
equal
deleted
inserted
replaced
4626:a6e2607021e0 | 4627:8f38a1bb9b79 |
---|---|
47 api.Handle("/users", sysAdmin(&mw.JSONHandler{ | 47 api.Handle("/users", sysAdmin(&mw.JSONHandler{ |
48 Input: func(*http.Request) interface{} { return new(models.User) }, | 48 Input: func(*http.Request) interface{} { return new(models.User) }, |
49 Handle: createUser, | 49 Handle: createUser, |
50 })).Methods(http.MethodPost) | 50 })).Methods(http.MethodPost) |
51 | 51 |
52 api.Handle("/users/{user}", any(&mw.JSONHandler{ | 52 api.Handle("/users/{user:.+}", any(&mw.JSONHandler{ |
53 Handle: listUser, | 53 Handle: listUser, |
54 })).Methods(http.MethodGet) | 54 })).Methods(http.MethodGet) |
55 | 55 |
56 api.Handle("/users/{user}", any(&mw.JSONHandler{ | 56 api.Handle("/users/{user:.+}", any(&mw.JSONHandler{ |
57 Input: func(*http.Request) interface{} { return new(models.User) }, | 57 Input: func(*http.Request) interface{} { return new(models.User) }, |
58 Handle: updateUser, | 58 Handle: updateUser, |
59 })).Methods(http.MethodPut) | 59 })).Methods(http.MethodPut) |
60 | 60 |
61 api.Handle("/users/{user}", sysAdmin(&mw.JSONHandler{ | 61 api.Handle("/users/{user:.+}", sysAdmin(&mw.JSONHandler{ |
62 Handle: deleteUser, | 62 Handle: deleteUser, |
63 })).Methods(http.MethodDelete) | 63 })).Methods(http.MethodDelete) |
64 | 64 |
65 // System notifications | 65 // System notifications |
66 api.Handle("/testmail/{user}", sysAdmin(&mw.JSONHandler{ | 66 api.Handle("/testmail/{user:.+}", sysAdmin(&mw.JSONHandler{ |
67 Handle: sendTestMail, | 67 Handle: sendTestMail, |
68 })).Methods(http.MethodGet) | 68 })).Methods(http.MethodGet) |
69 | 69 |
70 // System Management | 70 // System Management |
71 api.Handle("/system/log/{service}/{file}", sysAdmin(&mw.JSONHandler{ | 71 api.Handle("/system/log/{service}/{file}", sysAdmin(&mw.JSONHandler{ |
170 Handle: published, | 170 Handle: published, |
171 NoConn: true, | 171 NoConn: true, |
172 })).Methods(http.MethodGet) | 172 })).Methods(http.MethodGet) |
173 | 173 |
174 // Survey selection | 174 // Survey selection |
175 api.Handle("/surveys/{bottleneck}", any(&mw.JSONHandler{ | 175 api.Handle("/surveys/{bottleneck:.+}", any(&mw.JSONHandler{ |
176 Handle: listSurveys, | 176 Handle: listSurveys, |
177 })).Methods(http.MethodGet) | 177 })).Methods(http.MethodGet) |
178 | 178 |
179 // Bottlenecks | 179 // Bottlenecks |
180 api.Handle("/bottlenecks", any(&mw.JSONHandler{ | 180 api.Handle("/bottlenecks", any(&mw.JSONHandler{ |
310 Handle: reviewImport, | 310 Handle: reviewImport, |
311 })).Methods(http.MethodPut) | 311 })).Methods(http.MethodPut) |
312 | 312 |
313 // Handler to serve data to the client. | 313 // Handler to serve data to the client. |
314 | 314 |
315 api.Handle("/data/stretch/shape/{name}", any( | 315 api.Handle("/data/stretch/shape/{name:.+}", any( |
316 mw.DBConn(http.HandlerFunc(stretchShapeDownload)))).Methods(http.MethodGet) | 316 mw.DBConn(http.HandlerFunc(stretchShapeDownload)))).Methods(http.MethodGet) |
317 | 317 |
318 api.Handle("/data/{kind:stretch|section}/availability/{name}", any( | 318 api.Handle("/data/{kind:stretch|section}/availability/{name:.+}", any( |
319 mw.DBConn(http.HandlerFunc(stretchAvailabilty)))).Methods(http.MethodGet) | 319 mw.DBConn(http.HandlerFunc(stretchAvailabilty)))).Methods(http.MethodGet) |
320 | 320 |
321 api.Handle("/data/{kind:stretch|section}/fairway-depth/{name}", any( | 321 api.Handle("/data/{kind:stretch|section}/fairway-depth/{name:.+}", any( |
322 mw.DBConn(http.HandlerFunc(stretchAvailableFairwayDepth)))).Methods(http.MethodGet) | 322 mw.DBConn(http.HandlerFunc(stretchAvailableFairwayDepth)))).Methods(http.MethodGet) |
323 | 323 |
324 api.Handle("/data/bottleneck/fairway-depth/{objnam}", any( | 324 api.Handle("/data/bottleneck/fairway-depth/{objnam:.+}", any( |
325 mw.DBConn(http.HandlerFunc(bottleneckAvailableFairwayDepth)))).Methods(http.MethodGet) | 325 mw.DBConn(http.HandlerFunc(bottleneckAvailableFairwayDepth)))).Methods(http.MethodGet) |
326 | 326 |
327 api.Handle("/data/bottleneck/availability/{objnam}", any( | 327 api.Handle("/data/bottleneck/availability/{objnam:.+}", any( |
328 mw.DBConn(http.HandlerFunc(bottleneckAvailabilty)))).Methods(http.MethodGet) | 328 mw.DBConn(http.HandlerFunc(bottleneckAvailabilty)))).Methods(http.MethodGet) |
329 | 329 |
330 api.Handle("/data/waterlevels/{gauge}", any( | 330 api.Handle("/data/waterlevels/{gauge:.+}", any( |
331 mw.DBConn(http.HandlerFunc(waterlevels)))).Methods(http.MethodGet) | 331 mw.DBConn(http.HandlerFunc(waterlevels)))).Methods(http.MethodGet) |
332 | 332 |
333 api.Handle("/data/longterm-waterlevels/{gauge}", any( | 333 api.Handle("/data/longterm-waterlevels/{gauge:.+}", any( |
334 mw.DBConn(http.HandlerFunc(longtermWaterlevels)))).Methods(http.MethodGet) | 334 mw.DBConn(http.HandlerFunc(longtermWaterlevels)))).Methods(http.MethodGet) |
335 | 335 |
336 // TODO: gauge should not contain '/'s. | |
336 api.Handle("/data/year-waterlevels/{gauge}/{year:[0-9]+}", any( | 337 api.Handle("/data/year-waterlevels/{gauge}/{year:[0-9]+}", any( |
337 mw.DBConn(http.HandlerFunc(yearWaterlevels)))).Methods(http.MethodGet) | 338 mw.DBConn(http.HandlerFunc(yearWaterlevels)))).Methods(http.MethodGet) |
338 | 339 |
339 api.Handle("/data/nash-sutcliffe/{gauge}", any(&mw.JSONHandler{ | 340 api.Handle("/data/nash-sutcliffe/{gauge:.+}", any(&mw.JSONHandler{ |
340 Handle: nashSutcliffe, | 341 Handle: nashSutcliffe, |
341 })).Methods(http.MethodGet) | 342 })).Methods(http.MethodGet) |
342 | 343 |
343 // Token handling: Login/Logout. | 344 // Token handling: Login/Logout. |
344 api.HandleFunc("/login", login). | 345 api.HandleFunc("/login", login). |