# HG changeset patch # User Sascha L. Teichmann # Date 1570716791 -7200 # Node ID 8f38a1bb9b79efd9ffc7c69b4751d07af878d16e # Parent a6e2607021e05bd92f47bf1929efbdfd2f6be8d5 Applied {name:.+} workarounds in routing where applicable. diff -r a6e2607021e0 -r 8f38a1bb9b79 pkg/controllers/routes.go --- 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)