streamweave/http_server/
mod.rs

1//! # HTTP Server Support
2//!
3//! This module provides HTTP server capabilities for StreamWeave, enabling REST microservices
4//! with streaming request/response bodies through StreamWeave pipelines.
5//!
6//! ## Features
7//!
8//! - HTTP request producer that converts incoming HTTP requests to stream items
9//! - HTTP response consumer that converts stream items to HTTP responses
10//! - Streaming request/response body support
11//! - Axum integration for route handling and middleware
12//! - Support for REST API patterns (GET, POST, PUT, DELETE, etc.)
13//!
14//! ## Example
15//!
16//! ```rust,no_run
17//! use streamweave::http_server::{HttpRequest, HttpResponse};
18//! use axum::{Router, routing::get};
19//!
20//! // Create an HTTP server with StreamWeave pipeline integration
21//! let app = Router::new()
22//!     .route("/api/data", get(handle_request));
23//! ```
24//!
25//! ## Feature Flag
26//!
27//! This module requires the `http-server` feature flag to be enabled.
28
29#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
30pub mod consumer;
31/// Error handling utilities for HTTP server integration.
32#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
33pub mod error;
34#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
35pub mod handler;
36/// Input types for HTTP server integration.
37#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
38pub mod input;
39/// Middleware utilities for HTTP server integration.
40#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
41pub mod middleware;
42/// Output types for HTTP server integration.
43#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
44pub mod output;
45#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
46pub mod producer;
47#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
48pub mod types;
49
50#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
51pub use consumer::{HttpResponseConsumer, HttpResponseConsumerConfig};
52#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
53pub use error::{
54  ErrorDetails, ErrorResponse, create_custom_error, is_development_mode, map_generic_error,
55  map_to_http_error,
56};
57#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
58pub use handler::{create_pipeline_handler, create_simple_handler};
59#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
60pub use middleware::{
61  common_middleware_stack, cors_layer, cors_layer_with_origins, logging_layer, rate_limit_layer,
62};
63#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
64pub use producer::{HttpRequestProducer, HttpRequestProducerConfig};
65#[cfg(all(not(target_arch = "wasm32"), feature = "http-server"))]
66pub use types::{ContentType, HttpMethod, HttpRequest, HttpResponse};