@@ -31,7 +31,6 @@ import (
31
31
32
32
"github.com/gophercloud/gophercloud/v2"
33
33
"github.com/gophercloud/gophercloud/v2/openstack"
34
- "github.com/gorilla/mux"
35
34
"github.com/prometheus/client_golang/prometheus/promhttp"
36
35
"github.com/sapcc/go-api-declarations/liquid"
37
36
@@ -289,11 +288,11 @@ func limitRequestsMiddleware(maxRequests int) func(http.Handler) http.Handler {
289
288
}
290
289
291
290
// 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 )
297
296
}
298
297
299
298
func (rt * runtime ) handleGetInfo (w http.ResponseWriter , r * http.Request ) {
@@ -328,14 +327,13 @@ func (rt *runtime) handleReportUsage(w http.ResponseWriter, r *http.Request) {
328
327
if ! rt .requireToken (w , r , "liquid:get_usage" ) {
329
328
return
330
329
}
331
- vars := mux .Vars (r )
332
330
333
331
var req liquid.ServiceUsageRequest
334
332
if ! requireJSON (w , r , & req ) {
335
333
return
336
334
}
337
335
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 ())
339
337
if respondwith .ErrorText (w , err ) {
340
338
return
341
339
}
@@ -347,14 +345,13 @@ func (rt *runtime) handleSetQuota(w http.ResponseWriter, r *http.Request) {
347
345
if ! rt .requireToken (w , r , "liquid:set_quota" ) {
348
346
return
349
347
}
350
- vars := mux .Vars (r )
351
348
352
349
var req liquid.ServiceQuotaRequest
353
350
if ! requireJSON (w , r , & req ) {
354
351
return
355
352
}
356
353
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 ())
358
355
if respondwith .ErrorText (w , err ) {
359
356
return
360
357
}
@@ -363,7 +360,7 @@ func (rt *runtime) handleSetQuota(w http.ResponseWriter, r *http.Request) {
363
360
364
361
func (rt * runtime ) requireToken (w http.ResponseWriter , r * http.Request , policyRule string ) bool {
365
362
t := rt .TokenValidator .CheckToken (r )
366
- t .Context .Request = mux . Vars ( r )
363
+ t .Context .LookupRequestValue = r . PathValue
367
364
return t .Require (w , policyRule )
368
365
}
369
366
0 commit comments