Skip to main content

Crate moloch_api

Crate moloch_api 

Source
Expand description

API layer for Moloch audit chain.

This crate provides external access to the chain via:

  • REST API for CRUD operations
  • WebSocket for real-time subscriptions
  • Authentication and rate limiting

§Architecture

┌─────────────────────────────────────────────────────────┐
│                      API Server                         │
│  (Axum router with middleware stack)                    │
└─────────────────────────────────────────────────────────┘
                           │
          ┌────────────────┼────────────────┐
          ▼                ▼                ▼
┌─────────────────┐ ┌────────────┐ ┌───────────────────┐
│    REST API     │ │ WebSocket  │ │  Authentication   │
│  (events,blocks)│ │(subscribe) │ │  (JWT, API keys)  │
└─────────────────┘ └────────────┘ └───────────────────┘
          │                │                │
          └────────────────┼────────────────┘
                           ▼
┌─────────────────────────────────────────────────────────┐
│                    ApiState                             │
│  (Shared state: storage, index, consensus)              │
└─────────────────────────────────────────────────────────┘

Re-exports§

pub use auth::ApiKey;
pub use auth::AuthConfig;
pub use auth::AuthError;
pub use auth::AuthMiddleware;
pub use auth::Claims;
pub use rest::BlocksApi;
pub use rest::EventsApi;
pub use rest::ProofsApi;
pub use rest::StatusApi;
pub use server::ApiConfig;
pub use server::ApiServer;
pub use server::ApiState;
pub use ws::SubscriptionFilter;
pub use ws::WsHandler;
pub use ws::WsSubscription;

Modules§

auth
Authentication and authorization for the API.
rest
REST API endpoints for Moloch.
server
API server configuration and state.
ws
WebSocket subscriptions for real-time updates.