@@ -31,7 +31,6 @@ import (
3131
3232 "github.com/gophercloud/gophercloud/v2"
3333 "github.com/gophercloud/gophercloud/v2/openstack"
34- "github.com/gorilla/mux"
3534 "github.com/prometheus/client_golang/prometheus/promhttp"
3635 "github.com/sapcc/go-api-declarations/liquid"
3736
@@ -289,11 +288,11 @@ func limitRequestsMiddleware(maxRequests int) func(http.Handler) http.Handler {
289288}
290289
291290// AddTo implements the httpapi.API interface.
292- func (rt * runtime ) AddTo (r * mux. Router ) {
293- r . Methods ("GET" ). Path ( " /v1/info"). HandlerFunc ( rt .handleGetInfo )
294- r . Methods ("POST" ). Path ( " /v1/report-capacity"). HandlerFunc ( rt .handleReportCapacity )
295- r . Methods ("POST" ). Path ( " /v1/projects/{project_id}/report-usage"). HandlerFunc ( rt .handleReportUsage )
296- r . Methods ("PUT" ). Path ( " /v1/projects/{project_id}/quota"). HandlerFunc ( rt .handleSetQuota )
291+ func (rt * runtime ) AddTo (s * http. ServeMux ) {
292+ s . HandleFunc ("GET /v1/info" , rt .handleGetInfo )
293+ s . HandleFunc ("POST /v1/report-capacity" , rt .handleReportCapacity )
294+ s . HandleFunc ("POST /v1/projects/{project_id}/report-usage" , rt .handleReportUsage )
295+ s . HandleFunc ("PUT /v1/projects/{project_id}/quota" , rt .handleSetQuota )
297296}
298297
299298func (rt * runtime ) handleGetInfo (w http.ResponseWriter , r * http.Request ) {
@@ -328,14 +327,13 @@ func (rt *runtime) handleReportUsage(w http.ResponseWriter, r *http.Request) {
328327 if ! rt .requireToken (w , r , "liquid:get_usage" ) {
329328 return
330329 }
331- vars := mux .Vars (r )
332330
333331 var req liquid.ServiceUsageRequest
334332 if ! requireJSON (w , r , & req ) {
335333 return
336334 }
337335
338- resp , err := rt .Logic .ScanUsage (r .Context (), vars [ "project_id" ] , req , rt .getServiceInfo ())
336+ resp , err := rt .Logic .ScanUsage (r .Context (), r . PathValue ( "project_id" ) , req , rt .getServiceInfo ())
339337 if respondwith .ErrorText (w , err ) {
340338 return
341339 }
@@ -347,14 +345,13 @@ func (rt *runtime) handleSetQuota(w http.ResponseWriter, r *http.Request) {
347345 if ! rt .requireToken (w , r , "liquid:set_quota" ) {
348346 return
349347 }
350- vars := mux .Vars (r )
351348
352349 var req liquid.ServiceQuotaRequest
353350 if ! requireJSON (w , r , & req ) {
354351 return
355352 }
356353
357- err := rt .Logic .SetQuota (r .Context (), vars [ "project_id" ] , req , rt .getServiceInfo ())
354+ err := rt .Logic .SetQuota (r .Context (), r . PathValue ( "project_id" ) , req , rt .getServiceInfo ())
358355 if respondwith .ErrorText (w , err ) {
359356 return
360357 }
@@ -363,7 +360,7 @@ func (rt *runtime) handleSetQuota(w http.ResponseWriter, r *http.Request) {
363360
364361func (rt * runtime ) requireToken (w http.ResponseWriter , r * http.Request , policyRule string ) bool {
365362 t := rt .TokenValidator .CheckToken (r )
366- t .Context .Request = mux . Vars ( r )
363+ t .Context .LookupRequestValue = r . PathValue
367364 return t .Require (w , policyRule )
368365}
369366
0 commit comments