1- use aide:: axum:: { ApiRouter , IntoApiResponse , routing:: * } ;
1+ use aide:: {
2+ UseApi ,
3+ axum:: { ApiRouter , IntoApiResponse , routing:: * } ,
4+ } ;
25use axum:: {
36 Json ,
47 extract:: { Path , State } ,
@@ -147,7 +150,10 @@ struct EntitiesResponse {
147150 entities : Vec < EntityResponse > ,
148151}
149152
150- async fn get_users ( app : State < RouterState > , SessionUser ( user) : SessionUser ) -> ApiResult < impl IntoApiResponse > {
153+ async fn get_users (
154+ app : State < RouterState > ,
155+ SessionUser ( user) : SessionUser ,
156+ ) -> ApiResult < UseApi < impl IntoApiResponse , Json < UsersResponse > > > {
151157 if user. role != UserRole :: Admin {
152158 http_bail ! ( StatusCode :: FORBIDDEN , "Forbidden" )
153159 }
@@ -160,7 +166,7 @@ async fn get_users(app: State<RouterState>, SessionUser(user): SessionUser) -> A
160166 . map ( |u| UserResponse { username : u. username . clone ( ) , role : u. role , projects : u. projects . clone ( ) } )
161167 . collect ( ) ;
162168
163- Ok ( ( [ ( http:: header:: CACHE_CONTROL , "private" ) ] , Json ( UsersResponse { users } ) ) )
169+ Ok ( ( [ ( http:: header:: CACHE_CONTROL , "private" ) ] , Json ( UsersResponse { users } ) ) . into ( ) )
164170}
165171
166172async fn update_user (
@@ -295,7 +301,7 @@ async fn project_update_handler(
295301async fn projects_handler (
296302 app : State < RouterState > ,
297303 MaybeExtract ( user) : MaybeExtract < SessionUser > ,
298- ) -> ApiResult < impl IntoApiResponse > {
304+ ) -> ApiResult < UseApi < impl IntoApiResponse , Json < ProjectsResponse > > > {
299305 let projects = app. projects . all ( ) . http_err ( "Failed to get projects" , StatusCode :: INTERNAL_SERVER_ERROR ) ?;
300306 let projects: Vec < Project > = projects. into_iter ( ) . filter ( |p| can_access_project ( p, user. as_ref ( ) ) ) . collect ( ) ;
301307
@@ -315,14 +321,14 @@ async fn projects_handler(
315321 } ) ;
316322 }
317323
318- Ok ( ( [ ( http:: header:: CACHE_CONTROL , "private" ) ] , Json ( ProjectsResponse { projects : resp } ) ) )
324+ Ok ( ( [ ( http:: header:: CACHE_CONTROL , "private" ) ] , Json ( ProjectsResponse { projects : resp } ) ) . into ( ) )
319325}
320326
321327async fn project_handler (
322328 app : State < RouterState > ,
323329 MaybeExtract ( user) : MaybeExtract < SessionUser > ,
324330 Path ( project_id) : Path < String > ,
325- ) -> ApiResult < impl IntoApiResponse > {
331+ ) -> ApiResult < UseApi < impl IntoApiResponse , Json < ProjectResponse > > > {
326332 let project = app. projects . get ( & project_id) . http_status ( StatusCode :: NOT_FOUND ) ?;
327333 if !can_access_project ( & project, user. as_ref ( ) ) {
328334 return Err ( StatusCode :: NOT_FOUND . into ( ) ) ;
@@ -341,7 +347,7 @@ async fn project_handler(
341347 public : project. public ,
342348 } ) ;
343349
344- Ok ( ( [ ( http:: header:: CACHE_CONTROL , "private" ) ] , resp) )
350+ Ok ( ( [ ( http:: header:: CACHE_CONTROL , "private" ) ] , resp) . into ( ) )
345351}
346352
347353async fn project_delete_handler (
@@ -358,7 +364,10 @@ async fn project_delete_handler(
358364 Ok ( empty_response ( ) )
359365}
360366
361- async fn entities_handler ( app : State < RouterState > , SessionUser ( user) : SessionUser ) -> ApiResult < impl IntoApiResponse > {
367+ async fn entities_handler (
368+ app : State < RouterState > ,
369+ SessionUser ( user) : SessionUser ,
370+ ) -> ApiResult < UseApi < impl IntoApiResponse , Json < EntitiesResponse > > > {
362371 if user. role != UserRole :: Admin {
363372 http_bail ! ( StatusCode :: FORBIDDEN , "Forbidden" )
364373 }
@@ -384,7 +393,7 @@ async fn entities_handler(app: State<RouterState>, SessionUser(user): SessionUse
384393 } ) ;
385394 }
386395
387- Ok ( ( [ ( http:: header:: CACHE_CONTROL , "private" ) ] , Json ( EntitiesResponse { entities : resp } ) ) )
396+ Ok ( ( [ ( http:: header:: CACHE_CONTROL , "private" ) ] , Json ( EntitiesResponse { entities : resp } ) ) . into ( ) )
388397}
389398
390399async fn entity_create_handler (
0 commit comments