this repo has no description
1use crate::state::AppState; 2use axum::{Json, extract::State, http::StatusCode, response::IntoResponse}; 3use serde_json::json; 4use tracing::error; 5pub async fn robots_txt() -> impl IntoResponse { 6 ( 7 StatusCode::OK, 8 [("content-type", "text/plain")], 9 "# Hello!\n\n# Crawling the public API is allowed\nUser-agent: *\nAllow: /\n", 10 ) 11} 12pub async fn describe_server() -> impl IntoResponse { 13 let pds_hostname = std::env::var("PDS_HOSTNAME").unwrap_or_else(|_| "localhost".to_string()); 14 let domains_str = 15 std::env::var("AVAILABLE_USER_DOMAINS").unwrap_or_else(|_| pds_hostname.clone()); 16 let domains: Vec<&str> = domains_str.split(',').map(|s| s.trim()).collect(); 17 let invite_code_required = std::env::var("INVITE_CODE_REQUIRED") 18 .map(|v| v == "true" || v == "1") 19 .unwrap_or(false); 20 Json(json!({ 21 "availableUserDomains": domains, 22 "inviteCodeRequired": invite_code_required, 23 "did": format!("did:web:{}", pds_hostname), 24 "version": env!("CARGO_PKG_VERSION") 25 })) 26} 27pub async fn health(State(state): State<AppState>) -> impl IntoResponse { 28 match sqlx::query!("SELECT 1 as one").fetch_one(&state.db).await { 29 Ok(_) => (StatusCode::OK, "OK"), 30 Err(e) => { 31 error!("Health check failed: {:?}", e); 32 (StatusCode::SERVICE_UNAVAILABLE, "Service Unavailable") 33 } 34 } 35}