1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! `anyhow-http` offers customizable HTTP errors built on [`anyhow`] errors.
//!
//! This crates acts as a superset of [`anyhow`], extending the functionality to define custom
//! HTTP error responses.
//! # Example with `axum`
//!
//! ```rust,no_run
//! use axum::{
//! routing::get,
//! response::IntoResponse,
//! Router,
//! };
//! use anyhow_http::{http_error_bail, response::HttpJsonResult};
//!
//! #[tokio::main]
//! async fn main() {
//! let app = Router::new()
//! .route("/", get(handler));
//!
//! let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
//! .await
//! .unwrap();
//! axum::serve(listener, app).await.unwrap();
//! }
//!
//! fn fallible_operation() -> anyhow::Result<()> {
//! http_error_bail!(INTERNAL_SERVER_ERROR, "this is an error")
//! }
//!
//! async fn handler() -> HttpJsonResult<impl IntoResponse> {
//! fallible_operation()?;
//! Ok(())
//! }
//! ```
pub use *;
pub use *;
pub use http;