Skip to main content

Module api

Module api 

Source
Expand description

API layer for shell-tunnel.

This module provides REST API and WebSocket endpoints for interacting with shell sessions programmatically.

§Endpoints

§Health & Info

  • GET /health - Health check
  • GET /api/v1/ - API information

§Sessions

  • GET /api/v1/sessions - List all sessions
  • POST /api/v1/sessions - Create a new session
  • GET /api/v1/sessions/{id} - Get session status
  • DELETE /api/v1/sessions/{id} - Delete a session
  • POST /api/v1/sessions/{id}/execute - Execute command in session
  • WS /api/v1/sessions/{id}/ws - WebSocket for streaming

§One-shot Execution

  • POST /api/v1/execute - Execute command without session
  • WS /api/v1/ws - WebSocket for one-shot streaming

§Example

use shell_tunnel::api::{ServerConfig, serve};

#[tokio::main]
async fn main() -> shell_tunnel::Result<()> {
    let config = ServerConfig::new("127.0.0.1", 3000);
    serve(config).await
}

Re-exports§

pub use handlers::AppState;
pub use router::bind;
pub use router::create_router;
pub use router::create_router_with_state;
pub use router::create_secure_router;
pub use router::serve;
pub use router::serve_on;
pub use router::serve_with_state;
pub use router::CorsConfig;
pub use router::SecurityConfig;
pub use router::ServerConfig;
pub use types::CreateSessionRequest;
pub use types::CreateSessionResponse;
pub use types::ErrorResponse;
pub use types::ExecuteCommandRequest;
pub use types::ExecuteCommandResponse;
pub use types::ListSessionsResponse;
pub use types::SessionStatusResponse;
pub use types::WsMessage;

Modules§

handlers
REST API handlers.
router
API router configuration.
types
API request and response types.
websocket
WebSocket handler for real-time command streaming.