Mercurial > gemma
changeset 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 | a6e2607021e0 |
children | 28999c7c0c18 |
files | pkg/controllers/routes.go |
diffstat | 1 files changed, 14 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/routes.go Thu Oct 10 11:25:27 2019 +0200 +++ b/pkg/controllers/routes.go Thu Oct 10 16:13:11 2019 +0200 @@ -49,21 +49,21 @@ Handle: createUser, })).Methods(http.MethodPost) - api.Handle("/users/{user}", any(&mw.JSONHandler{ + api.Handle("/users/{user:.+}", any(&mw.JSONHandler{ Handle: listUser, })).Methods(http.MethodGet) - api.Handle("/users/{user}", any(&mw.JSONHandler{ + api.Handle("/users/{user:.+}", any(&mw.JSONHandler{ Input: func(*http.Request) interface{} { return new(models.User) }, Handle: updateUser, })).Methods(http.MethodPut) - api.Handle("/users/{user}", sysAdmin(&mw.JSONHandler{ + api.Handle("/users/{user:.+}", sysAdmin(&mw.JSONHandler{ Handle: deleteUser, })).Methods(http.MethodDelete) // System notifications - api.Handle("/testmail/{user}", sysAdmin(&mw.JSONHandler{ + api.Handle("/testmail/{user:.+}", sysAdmin(&mw.JSONHandler{ Handle: sendTestMail, })).Methods(http.MethodGet) @@ -172,7 +172,7 @@ })).Methods(http.MethodGet) // Survey selection - api.Handle("/surveys/{bottleneck}", any(&mw.JSONHandler{ + api.Handle("/surveys/{bottleneck:.+}", any(&mw.JSONHandler{ Handle: listSurveys, })).Methods(http.MethodGet) @@ -312,31 +312,32 @@ // Handler to serve data to the client. - api.Handle("/data/stretch/shape/{name}", any( + api.Handle("/data/stretch/shape/{name:.+}", any( mw.DBConn(http.HandlerFunc(stretchShapeDownload)))).Methods(http.MethodGet) - api.Handle("/data/{kind:stretch|section}/availability/{name}", any( + api.Handle("/data/{kind:stretch|section}/availability/{name:.+}", any( mw.DBConn(http.HandlerFunc(stretchAvailabilty)))).Methods(http.MethodGet) - api.Handle("/data/{kind:stretch|section}/fairway-depth/{name}", any( + api.Handle("/data/{kind:stretch|section}/fairway-depth/{name:.+}", any( mw.DBConn(http.HandlerFunc(stretchAvailableFairwayDepth)))).Methods(http.MethodGet) - api.Handle("/data/bottleneck/fairway-depth/{objnam}", any( + api.Handle("/data/bottleneck/fairway-depth/{objnam:.+}", any( mw.DBConn(http.HandlerFunc(bottleneckAvailableFairwayDepth)))).Methods(http.MethodGet) - api.Handle("/data/bottleneck/availability/{objnam}", any( + api.Handle("/data/bottleneck/availability/{objnam:.+}", any( mw.DBConn(http.HandlerFunc(bottleneckAvailabilty)))).Methods(http.MethodGet) - api.Handle("/data/waterlevels/{gauge}", any( + api.Handle("/data/waterlevels/{gauge:.+}", any( mw.DBConn(http.HandlerFunc(waterlevels)))).Methods(http.MethodGet) - api.Handle("/data/longterm-waterlevels/{gauge}", any( + api.Handle("/data/longterm-waterlevels/{gauge:.+}", any( mw.DBConn(http.HandlerFunc(longtermWaterlevels)))).Methods(http.MethodGet) + // TODO: gauge should not contain '/'s. api.Handle("/data/year-waterlevels/{gauge}/{year:[0-9]+}", any( mw.DBConn(http.HandlerFunc(yearWaterlevels)))).Methods(http.MethodGet) - api.Handle("/data/nash-sutcliffe/{gauge}", any(&mw.JSONHandler{ + api.Handle("/data/nash-sutcliffe/{gauge:.+}", any(&mw.JSONHandler{ Handle: nashSutcliffe, })).Methods(http.MethodGet)