INNER CODE UNIT · Rust

serve

zly2006/zhihu-plus-plus · aigc-vote-server/src/lib.rs:260

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()))
}

async fn healthz(State(state): State<AppState>) -> Result<Json<serde_json::Value>, ServiceError> {
    state.store.health().await?;
    Ok(Json(serde_json::json!({ "ok": true })))
}

async fn post_read_events(
    State(state): State<AppState>,
    Json(request): Json<ReadEventsRequest>,
) -> Result<Json<ReadEventsResponse>, ServiceError> {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…