use axum::{ Router, middleware, routing::{get, post}, }; use crate::{ auth::require_bearer_auth, square_hole::{ compile_square_hole_agent_draft, create_square_hole_agent_session, delete_square_hole_work, drop_square_hole_shape, execute_square_hole_agent_action, finish_square_hole_time_up, get_square_hole_agent_session, get_square_hole_run, get_square_hole_work_detail, get_square_hole_works, list_square_hole_gallery, publish_square_hole_work, put_square_hole_work, regenerate_square_hole_work_image, restart_square_hole_run, start_square_hole_run, stop_square_hole_run, stream_square_hole_agent_message, submit_square_hole_agent_message, }, state::AppState, }; pub fn router(state: AppState) -> Router { Router::new() .route( "/api/creation/square-hole/sessions", post(create_square_hole_agent_session).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/sessions/{session_id}", get(get_square_hole_agent_session).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/sessions/{session_id}/messages", post(submit_square_hole_agent_message).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/sessions/{session_id}/messages/stream", post(stream_square_hole_agent_message).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/sessions/{session_id}/actions", post(execute_square_hole_agent_action).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/sessions/{session_id}/compile", post(compile_square_hole_agent_draft).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/works", get(get_square_hole_works).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/works/{profile_id}", get(get_square_hole_work_detail) .patch(put_square_hole_work) .put(put_square_hole_work) .delete(delete_square_hole_work) .route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/works/{profile_id}/publish", post(publish_square_hole_work).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/creation/square-hole/works/{profile_id}/images/regenerate", post(regenerate_square_hole_work_image).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/runtime/square-hole/gallery", get(list_square_hole_gallery), ) .route( "/api/runtime/square-hole/works/{profile_id}/runs", post(start_square_hole_run).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/runtime/square-hole/runs/{run_id}", get(get_square_hole_run).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/runtime/square-hole/runs/{run_id}/drop", post(drop_square_hole_shape).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/runtime/square-hole/runs/{run_id}/stop", post(stop_square_hole_run).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/runtime/square-hole/runs/{run_id}/restart", post(restart_square_hole_run).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) .route( "/api/runtime/square-hole/runs/{run_id}/time-up", post(finish_square_hole_time_up).route_layer(middleware::from_fn_with_state( state.clone(), require_bearer_auth, )), ) }