Expand description
LLM Registry API Layer
This crate provides the REST API layer for the LLM Registry using Axum. It includes request handlers, middleware, error handling, and response types.
§Architecture
The API layer is organized into:
- Handlers: Request handlers for all API endpoints
- Routes: Route definitions and router configuration
- Middleware: Tower middleware for logging, CORS, compression, etc.
- Error Handling: Conversion of service errors to HTTP responses
- Responses: Standard response wrappers and types
§Example
use llm_registry_api::{build_router, AppState};
use llm_registry_service::ServiceRegistry;
use std::sync::Arc;
// Create application state
let state = AppState::new(services);
// Build router
let app = build_router(state);
// Run server (example)
// axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
// .serve(app.into_make_service())
// .await
// .unwrap();Re-exports§
pub use auth::AuthState;pub use auth::AuthUser;pub use auth::optional_auth;pub use auth::require_auth;pub use auth::require_role;pub use auth_handlers::AuthHandlerState;pub use auth_handlers::LoginRequest;pub use auth_handlers::LoginResponse;pub use auth_handlers::RefreshTokenRequest;pub use error::ApiError;pub use error::ApiResult;pub use error::ErrorResponse;pub use graphql::build_schema;pub use graphql::graphql_handler;pub use graphql::graphql_playground;pub use graphql::AppSchema;pub use graphql::Mutation as GraphQLMutation;pub use graphql::Query as GraphQLQuery;pub use grpc::build_grpc_server;pub use grpc::serve_grpc;pub use grpc::RegistryServiceImpl;pub use grpc::RegistryServiceServer;pub use handlers::AppState;pub use handlers::VersionInfo;pub use jwt::Claims;pub use jwt::JwtConfig;pub use jwt::JwtManager;pub use jwt::TokenPair;pub use middleware::CorsConfig;pub use middleware::MiddlewareConfig;pub use middleware::UuidRequestIdGenerator;pub use rate_limit::rate_limit;pub use rate_limit::RateLimitConfig;pub use rate_limit::RateLimiterState;pub use rbac::Permission;pub use rbac::RbacPolicy;pub use rbac::Role;pub use responses::created;pub use responses::deleted;pub use responses::no_content;pub use responses::ok;pub use responses::ApiResponse;pub use responses::ComponentHealth;pub use responses::EmptyResponse;pub use responses::HealthResponse;pub use responses::HealthStatus;pub use responses::PaginatedResponse;pub use responses::ResponseMeta;pub use routes::build_router;pub use routes::build_router_with_auth;pub use routes::build_router_with_graphql;pub use routes::RouteConfig;
Modules§
- auth
- Authentication middleware
- auth_
handlers - Authentication API handlers
- error
- API error handling
- graphql
- GraphQL API implementation
- grpc
- This module provides a complete gRPC API for the LLM Registry using Tonic. It supports all registry operations including streaming for real-time updates.
- handlers
- API request handlers
- jwt
- JWT token management
- metrics_
middleware - Metrics middleware for HTTP request tracking
- middleware
- API middleware
- rate_
limit - Rate limiting middleware
- rbac
- Role-Based Access Control (RBAC)
- responses
- API response types
- routes
- API route definitions
Functions§
- build_
api_ server - Build a complete API server with middleware
- build_
api_ server_ with_ config - Build API server with custom middleware configuration