shell_tunnel/api/mod.rs
1//! API layer for shell-tunnel.
2//!
3//! This module provides REST API and WebSocket endpoints for interacting
4//! with shell sessions programmatically.
5//!
6//! ## Endpoints
7//!
8//! ### Health & Info
9//! - `GET /health` - Health check
10//! - `GET /api/v1/` - API information
11//!
12//! ### Sessions
13//! - `GET /api/v1/sessions` - List all sessions
14//! - `POST /api/v1/sessions` - Create a new session
15//! - `GET /api/v1/sessions/{id}` - Get session status
16//! - `DELETE /api/v1/sessions/{id}` - Delete a session
17//! - `POST /api/v1/sessions/{id}/execute` - Execute command in session
18//! - `WS /api/v1/sessions/{id}/ws` - WebSocket for streaming
19//!
20//! ### One-shot Execution
21//! - `POST /api/v1/execute` - Execute command without session
22//! - `WS /api/v1/ws` - WebSocket for one-shot streaming
23//!
24//! ## Example
25//!
26//! ```no_run
27//! use shell_tunnel::api::{ServerConfig, serve};
28//!
29//! #[tokio::main]
30//! async fn main() -> shell_tunnel::Result<()> {
31//! let config = ServerConfig::new("127.0.0.1", 3000);
32//! serve(config).await
33//! }
34//! ```
35
36pub mod handlers;
37pub mod router;
38pub mod types;
39pub mod websocket;
40
41// Re-export commonly used types
42pub use handlers::AppState;
43pub use router::{
44 create_router, create_router_with_state, create_secure_router, serve, serve_with_state,
45 CorsConfig, SecurityConfig, ServerConfig,
46};
47pub use types::{
48 CreateSessionRequest, CreateSessionResponse, ErrorResponse, ExecuteCommandRequest,
49 ExecuteCommandResponse, ListSessionsResponse, SessionStatusResponse, WsMessage,
50};