7eae91d7d3
新增 play_flow 统一承接创作游玩与支撑路由 将 app.rs 的逐玩法挂载改为统一主干分发 将平台与资产及个人侧游玩支撑路由迁入 play_flow 抽出 visual_novel 路由模块并复用原有 handler 统一入口熔断路径解析并补充目标回归测试 更新后端契约、玩法链路和团队决策记录
184 lines
7.0 KiB
Rust
184 lines
7.0 KiB
Rust
use axum::{
|
|
Router, middleware,
|
|
routing::{get, post},
|
|
};
|
|
|
|
use crate::{
|
|
auth::require_bearer_auth,
|
|
state::AppState,
|
|
vector_engine_audio_generation::{
|
|
create_background_music_task, create_sound_effect_task,
|
|
create_visual_novel_background_music_task, create_visual_novel_sound_effect_task,
|
|
publish_background_music_asset, publish_sound_effect_asset,
|
|
publish_visual_novel_background_music_asset, publish_visual_novel_sound_effect_asset,
|
|
},
|
|
visual_novel::{
|
|
compile_visual_novel_session, create_visual_novel_session, delete_visual_novel_work,
|
|
execute_visual_novel_action, get_visual_novel_run, get_visual_novel_session,
|
|
get_visual_novel_work, list_visual_novel_gallery, list_visual_novel_history,
|
|
list_visual_novel_works, publish_visual_novel_work, regenerate_visual_novel_run,
|
|
start_visual_novel_run, stream_visual_novel_action, stream_visual_novel_message,
|
|
submit_visual_novel_message, update_visual_novel_work,
|
|
},
|
|
};
|
|
|
|
pub fn router(state: AppState) -> Router<AppState> {
|
|
Router::new()
|
|
.route(
|
|
"/api/creation/visual-novel/sessions",
|
|
post(create_visual_novel_session).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}",
|
|
get(get_visual_novel_session).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}/messages",
|
|
post(submit_visual_novel_message).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}/messages/stream",
|
|
post(stream_visual_novel_message).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}/actions",
|
|
post(execute_visual_novel_action).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/sessions/{session_id}/compile",
|
|
post(compile_visual_novel_session).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/works",
|
|
get(list_visual_novel_works).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/works/{profile_id}",
|
|
get(get_visual_novel_work)
|
|
.put(update_visual_novel_work)
|
|
.patch(update_visual_novel_work)
|
|
.delete(delete_visual_novel_work)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/works/{profile_id}/publish",
|
|
post(publish_visual_novel_work).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/audio/background-music",
|
|
post(create_visual_novel_background_music_task).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/audio/background-music/{task_id}/asset",
|
|
post(publish_visual_novel_background_music_asset).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/audio/sound-effect",
|
|
post(create_visual_novel_sound_effect_task).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/creation/visual-novel/audio/sound-effect/{task_id}/asset",
|
|
post(publish_visual_novel_sound_effect_asset).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/creation/audio/background-music",
|
|
post(create_background_music_task).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/audio/background-music/{task_id}/asset",
|
|
post(publish_background_music_asset).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/audio/sound-effect",
|
|
post(create_sound_effect_task).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/creation/audio/sound-effect/{task_id}/asset",
|
|
post(publish_sound_effect_asset).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/gallery",
|
|
get(list_visual_novel_gallery),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/works/{profile_id}/runs",
|
|
post(start_visual_novel_run).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/runs/{run_id}",
|
|
get(get_visual_novel_run).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/runs/{run_id}/actions/stream",
|
|
post(stream_visual_novel_action).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/runs/{run_id}/history",
|
|
get(list_visual_novel_history).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/visual-novel/runs/{run_id}/regenerate",
|
|
post(regenerate_visual_novel_run)
|
|
.route_layer(middleware::from_fn_with_state(state, require_bearer_auth)),
|
|
)
|
|
}
|