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