domainstack-http 1.0.0

Framework-agnostic HTTP helpers for domainstack: boundary validation for web APIs
Documentation

domainstack-http

Blackwell Systems™ Crates.io Documentation License: MIT OR Apache-2.0

Framework-agnostic HTTP error handling for the domainstack full-stack validation ecosystem.

Overview

This crate provides shared HTTP error types and utilities used by framework-specific adapters like domainstack-axum and domainstack-actix.

Most users should use framework adapters directly instead of this crate:

Usage

Only use this crate directly if you're:

  1. Building a new framework adapter for domainstack
  2. Need framework-agnostic error handling

Add this to your Cargo.toml:

[dependencies]
domainstack = "1.0"
domainstack-http = "1.0"

Types

ErrorResponse - Framework-agnostic HTTP error response:

use domainstack_http::ErrorResponse;
use domainstack::ValidationError;

let validation_error = ValidationError::single(
    Path::from("email"),
    "invalid_email",
    "Invalid email format"
);

let response = ErrorResponse::from(validation_error);
// Contains error-envelope formatted response with 400 status

Framework Adapters

This crate is used internally by:

  • domainstack-axum - Implements IntoResponse for Axum
  • domainstack-actix - Implements ResponseError for Actix-web

Both adapters use ErrorResponse as their common error type and add framework-specific trait implementations.

Building Custom Adapters

If you're integrating domainstack with another web framework:

  1. Add domainstack-http and domainstack-envelope dependencies
  2. Use ErrorResponse as your error type
  3. Implement your framework's error trait
  4. Convert ErrorResponse::inner (which is error_envelope::Error) to your framework's response type

See domainstack-axum or domainstack-actix source code for reference implementations.

Documentation

For complete documentation and examples, see:

License

Apache 2.0