dyson_http
Dyson HTTP helpers for Axum services. This crate gives you:
- A ready-to-merge health check route:
/actuator/health. - A simple way to serve interactive API docs (Swagger UI, Redoc, RapiDoc, Scalar) backed by
utoipa. - Small macros to make wiring routes and documenting endpoints ergonomic.
Works great for small services or bootstrapping new ones quickly.
Install
Add these to your Cargo.toml:
[]
= "0.8"
= "0"
# You write the OpenAPI derives and use the axum routes macro in your app,
# so you also need these dependencies in your crate:
= { = "5", = ["axum_extras"] }
= "0"
If you're working inside a workspace with this repo checked out, you can also use a path dependency while developing:
[]
= { = "../../crates/dyson_http" }
Features
- Health check route
dyson_http::http::health_check_routes()merges a simpleGET /actuator/health=>OK.
- API documentation router
dyson_http::http::docs::router_with_docs(OpenApiRouter)exposes:- Swagger UI at
/swagger-ui - Redoc at
/redoc - RapiDoc at
/rapidoc - Scalar (Minimal UI) at
/ - OpenAPI JSON is served from
/api/v1/openapi.json.
- Swagger UI at
- Doc helpers
- Security scheme add-ons:
ApiKeySecuritySchemeAddon,JwtSecuritySchemeAddon(implementutoipa::Modify). - Route helpers/macros:
register_routes!,route_docs!, androute_docs_with_name!to help enrich operations.
- Security scheme add-ons:
Quick start
1) Health check only
use ;
async
2) Add interactive API docs (Swagger UI, Redoc, RapiDoc, Scalar)
The example below shows a minimal API with a documented endpoint using utoipa. The register_routes! macro helps collect routes for your OpenAPI and the router_with_docs function exposes the documentation UIs.
use ;
use ;
use ;
use OpenApiRouter;
/// Simple hello endpoint
async
;
async
Docs will be available at:
- Swagger UI: http://localhost:3000/swagger-ui
- Redoc: http://localhost:3000/redoc
- RapiDoc: http://localhost:3000/rapidoc
- Scalar: http://localhost:3000/
- OpenAPI JSON: http://localhost:3000/http/v1/openapi.json
3) Optional: Add security schemes to your OpenAPI
If you need API key or JWT bearer auth schemes, you can apply our modifiers to your OpenApi:
use Modify;
;
License
Licensed under either of
- Apache License, Version 2.0
- MIT license
at your option.