INNER CODE UNIT · Rust
app
zly2006/zhihu-plus-plus · aigc-vote-server/src/lib.rs:249
pub fn app(state: AppState) -> Router {
Router::new()
.route("/healthz", get(healthz))
.route("/v1/read-events:batch", post(post_read_events))
.route(
"/v1/contents/{content_type}/{content_id}/aigc-flag",
get(get_flag_status).post(post_aigc_flag),
)
.with_state(state)
}
pub async fn serve(state: AppState, addr: SocketAddr) -> Result<(), ServiceError> {
let listener = tokio::net::TcpListener::bind(addr)
.await
.map_err(|error| ServiceError::internal(error.to_string()))?;
axum::serve(listener, app(state))
.await
.map_err(|error| ServiceError::internal(error.to_string()))