@@ -68,7 +68,7 @@ async fn auth_required_middleware<A: Adapter>(
68
68
if req. extensions ( ) . get :: < Session > ( ) . is_some ( ) {
69
69
Ok ( req)
70
70
} else {
71
- Err ( ResponseError :: UnAuthorized )
71
+ Err ( ResponseError :: Unauthorized )
72
72
}
73
73
}
74
74
@@ -219,14 +219,14 @@ async fn channels_router<A: Adapter>(
219
219
220
220
// example with middleware
221
221
// @TODO remove later
222
- let req = match chain ( req, & app, vec ! [ config_middleware] ) . await {
222
+ let req = match chain ( req, app, vec ! [ config_middleware] ) . await {
223
223
Ok ( req) => req,
224
224
Err ( error) => {
225
225
return Err ( error) ;
226
226
}
227
227
} ;
228
228
229
- last_approved ( req, & app) . await
229
+ last_approved ( req, app) . await
230
230
} else if let ( Some ( caps) , & Method :: GET ) =
231
231
( CHANNEL_STATUS_BY_CHANNEL_ID . captures ( & path) , method)
232
232
{
@@ -235,14 +235,14 @@ async fn channels_router<A: Adapter>(
235
235
. map_or( "" . to_string( ) , |m| m. as_str( ) . to_string( ) ) ] ) ;
236
236
req. extensions_mut ( ) . insert ( param) ;
237
237
238
- let req = match chain ( req, & app, vec ! [ channel_load] ) . await {
238
+ let req = match chain ( req, app, vec ! [ channel_load] ) . await {
239
239
Ok ( req) => req,
240
240
Err ( error) => {
241
241
return Err ( error) ;
242
242
}
243
243
} ;
244
244
245
- channel_status ( req, & app) . await
245
+ channel_status ( req, app) . await
246
246
} else if let ( Some ( caps) , & Method :: GET ) = ( CHANNEL_VALIDATOR_MESSAGES . captures ( & path) , method)
247
247
{
248
248
let param = RouteParams ( vec ! [ caps
@@ -251,7 +251,7 @@ async fn channels_router<A: Adapter>(
251
251
252
252
req. extensions_mut ( ) . insert ( param) ;
253
253
254
- let req = match chain ( req, & app, vec ! [ channel_load] ) . await {
254
+ let req = match chain ( req, app, vec ! [ channel_load] ) . await {
255
255
Ok ( req) => req,
256
256
Err ( error) => {
257
257
return Err ( error) ;
@@ -267,11 +267,9 @@ async fn channels_router<A: Adapter>(
267
267
} ;
268
268
269
269
list_validator_messages ( req, & app, & extract_params. 0 , & extract_params. 1 ) . await
270
- } else if let ( Some ( caps) , & Method :: GET ) =
271
- ( CHANNEL_EVENTS_AGGREGATES . captures ( path) , method)
272
- {
270
+ } else if let ( Some ( caps) , & Method :: GET ) = ( CHANNEL_EVENTS_AGGREGATES . captures ( & path) , method) {
273
271
if req. extensions ( ) . get :: < Session > ( ) . is_none ( ) {
274
- return map_response_error ( ResponseError :: Unauthorized ) ;
272
+ return Err ( ResponseError :: Unauthorized ) ;
275
273
}
276
274
277
275
let param = RouteParams ( vec ! [
@@ -282,14 +280,9 @@ async fn channels_router<A: Adapter>(
282
280
] ) ;
283
281
req. extensions_mut ( ) . insert ( param) ;
284
282
285
- let req = match chain ( req, & self , vec ! [ channel_load] ) . await {
286
- Ok ( req) => req,
287
- Err ( error) => {
288
- return map_response_error ( error) ;
289
- }
290
- } ;
283
+ let req = chain ( req, app, vec ! [ channel_load] ) . await ?;
291
284
292
- list_channel_event_aggregates ( req, & self ) . await
285
+ list_channel_event_aggregates ( req, app ) . await
293
286
} else {
294
287
Err ( ResponseError :: NotFound )
295
288
}
@@ -299,7 +292,7 @@ async fn channels_router<A: Adapter>(
299
292
pub enum ResponseError {
300
293
NotFound ,
301
294
BadRequest ( String ) ,
302
- UnAuthorized ,
295
+ Unauthorized ,
303
296
}
304
297
305
298
impl < T > From < T > for ResponseError
@@ -317,7 +310,7 @@ pub fn map_response_error(error: ResponseError) -> Response<Body> {
317
310
match error {
318
311
ResponseError :: NotFound => not_found ( ) ,
319
312
ResponseError :: BadRequest ( e) => bad_response ( e, StatusCode :: BAD_REQUEST ) ,
320
- ResponseError :: UnAuthorized => bad_response (
313
+ ResponseError :: Unauthorized => bad_response (
321
314
"invalid authorization" . to_string ( ) ,
322
315
StatusCode :: UNAUTHORIZED ,
323
316
) ,
0 commit comments