@@ -9,13 +9,13 @@ use std::{str::FromStr, sync::Arc, time::Duration};
99
1010use anyhow:: { Context , Error } ;
1111use axum:: {
12- extract:: { Host , MatchedPath , OriginalUri , Request } ,
12+ extract:: { MatchedPath , OriginalUri , Request } ,
1313 middleware:: { from_fn, from_fn_with_state, FromFnLayer } ,
1414 response:: { IntoResponse , Redirect } ,
1515 routing:: { get, post} ,
1616 Extension , Router ,
1717} ;
18- use axum_extra:: middleware:: option_layer;
18+ use axum_extra:: { extract :: Host , middleware:: option_layer} ;
1919use candid:: Principal ;
2020use domain:: { CustomDomainStorage , DomainResolver , ProvidesCustomDomains } ;
2121use fqdn:: FQDN ;
@@ -102,14 +102,14 @@ impl From<Option<&MatchedPath>> for RequestType {
102102 } ;
103103
104104 match path. as_str ( ) {
105- "/api/v2/canister/: principal/query" => Self :: Api ( RequestTypeApi :: Query ) ,
106- "/api/v2/canister/: principal/call" => Self :: Api ( RequestTypeApi :: Call ) ,
107- "/api/v3/canister/: principal/call" => Self :: Api ( RequestTypeApi :: SyncCall ) ,
108- "/api/v2/canister/: principal/read_state" => Self :: Api ( RequestTypeApi :: ReadState ) ,
109- "/api/v2/subnet/: principal/read_state" => Self :: Api ( RequestTypeApi :: ReadStateSubnet ) ,
105+ "/api/v2/canister/{ principal} /query" => Self :: Api ( RequestTypeApi :: Query ) ,
106+ "/api/v2/canister/{ principal} /call" => Self :: Api ( RequestTypeApi :: Call ) ,
107+ "/api/v3/canister/{ principal} /call" => Self :: Api ( RequestTypeApi :: SyncCall ) ,
108+ "/api/v2/canister/{ principal} /read_state" => Self :: Api ( RequestTypeApi :: ReadState ) ,
109+ "/api/v2/subnet/{ principal} /read_state" => Self :: Api ( RequestTypeApi :: ReadStateSubnet ) ,
110110 "/api/v2/status" => Self :: Api ( RequestTypeApi :: Status ) ,
111111 "/health" => Self :: Health ,
112- "/registrations" | "/registrations/:id " => Self :: Registrations ,
112+ "/registrations" | "/registrations/{id} " => Self :: Registrations ,
113113 _ => Self :: Unknown ,
114114 }
115115 }
@@ -244,15 +244,13 @@ pub fn setup_router(
244244 } ;
245245
246246 // Metrics
247- let metrics_mw = from_fn_with_state (
248- Arc :: new ( metrics:: HttpMetrics :: new (
249- registry,
250- cli. log . log_requests ,
251- clickhouse,
252- vector,
253- ) ) ,
254- metrics:: middleware,
255- ) ;
247+ let metrics_state = Arc :: new ( metrics:: HttpMetrics :: new (
248+ registry,
249+ cli. log . log_requests ,
250+ clickhouse,
251+ vector,
252+ ) ) ;
253+ let metrics_mw = from_fn_with_state ( metrics_state, metrics:: middleware) ;
256254
257255 // Concurrency
258256 let concurrency_limit_mw = option_layer (
@@ -333,19 +331,19 @@ pub fn setup_router(
333331 // IC API proxy routers
334332 let router_api_v2 = Router :: new ( )
335333 . route (
336- "/canister/: principal/query" ,
334+ "/canister/{ principal} /query" ,
337335 post ( proxy:: api_proxy) . layer ( cors_post. clone ( ) ) ,
338336 )
339337 . route (
340- "/canister/: principal/call" ,
338+ "/canister/{ principal} /call" ,
341339 post ( proxy:: api_proxy) . layer ( cors_post. clone ( ) ) ,
342340 )
343341 . route (
344- "/canister/: principal/read_state" ,
342+ "/canister/{ principal} /read_state" ,
345343 post ( proxy:: api_proxy) . layer ( cors_post. clone ( ) ) ,
346344 )
347345 . route (
348- "/subnet/: principal/read_state" ,
346+ "/subnet/{ principal} /read_state" ,
349347 post ( proxy:: api_proxy) . layer ( cors_post. clone ( ) ) ,
350348 )
351349 . route ( "/status" , get ( proxy:: api_proxy) . layer ( cors_get. clone ( ) ) )
@@ -354,7 +352,7 @@ pub fn setup_router(
354352
355353 let router_api_v3 = Router :: new ( )
356354 . route (
357- "/canister/: principal/call" ,
355+ "/canister/{ principal} /call" ,
358356 post ( proxy:: api_proxy) . layer ( cors_post. clone ( ) ) ,
359357 )
360358 . fallback ( || async { ( StatusCode :: NOT_FOUND , "" ) } )
@@ -421,7 +419,7 @@ pub fn setup_router(
421419
422420 let router = Router :: new ( )
423421 . route (
424- "/registrations/:id " ,
422+ "/registrations/{id} " ,
425423 get ( proxy:: issuer_proxy)
426424 . put ( proxy:: issuer_proxy)
427425 . delete ( proxy:: issuer_proxy)
0 commit comments