http-api-problem

A Rust library for building RFC 7807 problem+json HTTP error responses for APIs.

Library
Cargo
v0.60.0
62stars
Apache-2.0 OR MIT

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
33/100Needs Attention
Development Activity0
Maintenance20
Community40
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture76
Code Quality74
Innovation68
Learning Curve80

http-api-problem is a small Rust library for producing machine-readable HTTP error responses that conform to RFC 7807 (Problem Details for HTTP APIs). It centers on an HttpApiProblem type with a fluent builder for setting the status, title, detail, type URL, and instance of a problem.

The type serializes to and from the standard application/problem+json media type via serde, and optional feature flags provide first-class integrations with popular web frameworks including actix-web, axum, warp, rocket, salvo, tide, and hyper so returning a well-formed problem response fits naturally into each framework’s handlers.

What You Get

  • An HttpApiProblem type with a chainable builder for status, title, detail, type URL, and instance
  • serde Serialize/Deserialize producing the application/problem+json representation
  • Optional integrations for actix-web, axum, warp, rocket, salvo, tide, and hyper
  • An ApiError type and derive macro (via the api-error feature) for richer error handling
  • Optional JSON Schema generation through the schemars-based json-schema feature

Common Use Cases

  • Returning consistent, standards-based error bodies from a Rust HTTP API
  • Mapping internal errors into problem+json responses inside a web framework handler
  • Sharing a documented, self-describing error contract with API consumers

Under The Hood

Architecture — The crate is deliberately small. src/lib.rs defines the HttpApiProblem struct with optional status, title, detail, type_url, and instance fields plus a builder-style API, and derives serde Serialize/Deserialize to emit application/problem+json. src/api_error.rs layers a richer ApiError abstraction (gated by the api-error feature) on top, and framework conversions are compiled in only when the corresponding feature flag is enabled. src/test.rs holds the test suite.

Tech Stack — Rust (edition 2021) built on serde, serde_json, and the http crate for status codes. Every web-framework dependency (hyper, actix-web, axum-core, warp, rocket, salvo, tide) is optional and behind a feature flag, and a companion http-api-problem-derive proc-macro crate lives in the workspace for the api-error feature.

Code Quality — Idiomatic, focused Rust with an ergonomic fluent builder and thorough rustdoc examples that double as doc-tests. Tests live in src/test.rs; the codebase is compact (a couple of source files, ~59 KB of Rust) and easy to audit, though the project has seen little recent activity.

API Design — The public surface is minimal and discoverable: HttpApiProblem::new(status).title(..).detail(..).type_url(..).instance(..), plus try_new(u16) for dynamic status codes. Feature-gated From/IntoResponse conversions mean adopting it in an existing framework usually costs a single import and one enum arm, keeping boilerplate low.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search