typeway-server 0.1.0

Server runtime for the typeway type-level web framework
Documentation
//! `typeway-server` — Tower/Hyper server integration for the Typeway web framework.
//!
//! This crate provides the HTTP server layer: handler dispatch, request
//! extraction, response encoding, and the type-safe server builder.

pub mod auth;
#[cfg(feature = "axum-interop")]
pub mod axum_interop;
pub mod body;
pub mod effects;
pub mod error;
pub mod extract;
#[cfg(feature = "grpc")]
pub mod grpc;
#[cfg(feature = "protobuf")]
pub mod grpc_direct;
#[cfg(feature = "grpc")]
pub mod grpc_dispatch;
#[cfg(feature = "grpc")]
pub mod grpc_stream;
pub mod handler;
pub mod handler_for;
pub mod mount;
#[cfg(feature = "multipart")]
pub mod multipart;
pub mod negotiate;
#[cfg(feature = "openapi")]
pub mod openapi;
pub mod production;
#[cfg(feature = "protobuf")]
pub mod proto_extract;
pub mod request_id;
pub mod response;
pub mod router;
pub mod secure_headers;
pub mod server;
pub mod serves;
pub mod sse;
#[cfg(feature = "tls")]
pub mod tls;
pub mod typed;
pub mod typed_bind;
pub mod typed_response;
#[cfg(feature = "ws")]
pub mod typed_ws;
#[cfg(feature = "ws")]
pub mod ws;

pub use body::{body_from_stream, empty_body, sse_body, BoxBody};
pub use effects::{EffectfulLayeredServer, EffectfulServer};
pub use error::JsonError;
pub use extract::{
    Cookie, CookieJar, Extension, FromRequest, FromRequestParts, Header, NamedCookie, NamedHeader,
    Path, PathPrefixOffset, Query, State,
};
pub use handler::{into_boxed_handler, BoxedHandler, Handler, ResponseFuture};
pub use handler_for::{bind, BindableEndpoint, BoundHandler};
pub use mount::ServerBuilder;
pub use negotiate::{
    AcceptHeader, CsvFormat, HtmlFormat, JsonFormat, NegotiateFormats, NegotiatedResponse,
    RenderAs, RenderAsXml, TextFormat, XmlFormat,
};
pub use response::{IntoResponse, Json};
pub use router::{Router, RouterService};
pub use secure_headers::SecureHeadersLayer;
pub use server::{serve, LayeredServer, Server};
pub use serves::{Serves, SubApi};
pub use sse::{keep_alive, SseEvent, SseResponse};

#[cfg(feature = "grpc")]
pub use grpc::{GrpcServer, LayeredGrpcServer};
#[cfg(feature = "protobuf")]
pub use grpc_direct::into_direct_handler;
#[cfg(feature = "grpc")]
pub use grpc_stream::{GrpcStream, GrpcStreamSender};
#[cfg(feature = "protobuf")]
pub use proto_extract::Proto;

/// Re-export tower-http for middleware layers.
pub use tower_http;

/// Re-export tracing for structured logging.
pub use tracing;

/// Collect handler doc constants into a slice for [`Server::with_openapi_docs`].
///
/// Pass the `SCREAMING_SNAKE_CASE_DOC` constants generated by
/// `#[documented_handler]`.
///
/// # Example
///
/// ```ignore
/// use typeway_macros::documented_handler;
/// use typeway_server::handler_docs;
///
/// /// List users.
/// #[documented_handler(tags = "users")]
/// async fn list_users() -> Json<Vec<User>> { /* ... */ }
///
/// /// Get one user.
/// #[documented_handler(tags = "users")]
/// async fn get_user(id: Path<u32>) -> Json<User> { /* ... */ }
///
/// Server::<API>::new(handlers)
///     .with_openapi_docs("My API", "1.0", &handler_docs![
///         LIST_USERS_DOC,
///         GET_USER_DOC,
///     ])
///     .serve(addr)
///     .await?;
/// ```
#[macro_export]
macro_rules! handler_docs {
    ($($doc:expr),* $(,)?) => {
        [$($doc),*]
    };
}