@@ -9,9 +9,12 @@ mod utils;
99
1010use axum:: { routing:: get, Router } ;
1111
12- use models:: SharedState ;
12+ use models:: app_state :: SharedState ;
1313use repository:: todo:: { Repo , TodoRepo } ;
14- use routes:: htmx:: index:: { create_htmx_routes, get_index} ;
14+ use routes:: {
15+ htmx:: index:: { create_htmx_routes, get_index} ,
16+ json:: index:: create_json_routes,
17+ } ;
1518use service:: todo:: { TodoService , TodoServiceImpl } ;
1619use tokio:: net:: TcpListener ;
1720use tower_http:: { services:: ServeDir , trace:: TraceLayer } ;
@@ -22,12 +25,11 @@ pub fn app() -> Router {
2225 let todo_repo = TodoRepo :: new ( SharedState :: default ( ) ) ;
2326 let todo_service = TodoServiceImpl :: new ( todo_repo) ;
2427
25- let htmx_routes = create_htmx_routes ( ) ;
26-
2728 Router :: new ( )
2829 . nest_service ( "/assets" , ServeDir :: new ( "assets" ) )
2930 . route ( "/" , get ( get_index) )
30- . nest ( "/htmx-api" , htmx_routes)
31+ . nest ( "/htmx-api" , create_htmx_routes ( ) )
32+ . nest ( "/json-api" , create_json_routes ( ) )
3133 . layer ( TraceLayer :: new_for_http ( ) )
3234 . with_state ( todo_service)
3335}
0 commit comments