7dd53e95d8
统一推荐页各玩法正式 runtime 的游客鉴权透传。 收口推荐页首页展示队列和嵌入运行态切换队列。 补齐未登录读档、签名资产和个人数据读取的游客态处理。 新增运行态 HUD 小尺寸 logo 资源并更新拼图与抓鹅展示。 补充推荐切换、runtime guest 启动和客户端请求回归测试。 更新玩法链路、后端契约和团队记忆文档。
120 lines
4.3 KiB
Rust
120 lines
4.3 KiB
Rust
use axum::{
|
|
Router, middleware,
|
|
routing::{delete, get, post},
|
|
};
|
|
|
|
use crate::{
|
|
auth::{require_bearer_auth, require_runtime_principal_auth},
|
|
big_fish::{
|
|
create_big_fish_session, delete_big_fish_work, execute_big_fish_action, get_big_fish_run,
|
|
get_big_fish_session, get_big_fish_works, list_big_fish_gallery,
|
|
record_big_fish_gallery_like, record_big_fish_play, remix_big_fish_gallery_work,
|
|
start_big_fish_run, stream_big_fish_message, submit_big_fish_input,
|
|
submit_big_fish_message,
|
|
},
|
|
state::AppState,
|
|
};
|
|
|
|
pub fn router(state: AppState) -> Router<AppState> {
|
|
Router::new()
|
|
.route(
|
|
"/api/runtime/big-fish/agent/sessions",
|
|
post(create_big_fish_session).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/agent/sessions/{session_id}",
|
|
get(get_big_fish_session).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/agent/sessions/{session_id}/messages",
|
|
post(submit_big_fish_message).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/agent/sessions/{session_id}/messages/stream",
|
|
post(stream_big_fish_message).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/agent/sessions/{session_id}/actions",
|
|
post(execute_big_fish_action).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/works",
|
|
get(get_big_fish_works).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route("/api/runtime/big-fish/gallery", get(list_big_fish_gallery))
|
|
.route(
|
|
"/api/runtime/big-fish/gallery/{session_id}/remix",
|
|
post(remix_big_fish_gallery_work).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/gallery/{session_id}/like",
|
|
post(record_big_fish_gallery_like).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/works/{session_id}",
|
|
delete(delete_big_fish_work).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/sessions/{session_id}/play",
|
|
post(record_big_fish_play).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/works/{session_id}/play",
|
|
post(record_big_fish_play).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/sessions/{session_id}/runs",
|
|
post(start_big_fish_run).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/runs/{run_id}",
|
|
get(get_big_fish_run).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/runtime/big-fish/runs/{run_id}/input",
|
|
post(submit_big_fish_input).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_runtime_principal_auth,
|
|
)),
|
|
)
|
|
}
|