Skip to main content
Glama
axum_integration.rs1.04 kB
use std::sync::Arc; use axum::{ Router, extract::State, http::StatusCode, response::{ IntoResponse, Json, }, routing::get, }; use serde_json::json; use tower_http::cors::CorsLayer; use crate::{ DefaultServiceEndpoints, ServiceEndpointsConfig, }; pub fn create_router( service: Arc<DefaultServiceEndpoints>, config: &ServiceEndpointsConfig, ) -> Router { Router::new() .route(&config.health_endpoint, get(health_handler)) .route(&config.config_endpoint, get(config_handler)) .layer(CorsLayer::permissive()) .with_state(service) } async fn health_handler(State(_service): State<Arc<DefaultServiceEndpoints>>) -> impl IntoResponse { (StatusCode::OK, Json(json!({ "status": "healthy" }))) } async fn config_handler(State(service): State<Arc<DefaultServiceEndpoints>>) -> impl IntoResponse { let response = json!({ "service": service.service_name(), "config": service.config() }); (StatusCode::OK, Json(response)) }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server