HTTP-API-PROBLEM
A library to create HTTP response content for APIs based on RFC7807.
Usage
Get the latest version for your Cargo.toml
from
crates.io.
Serde
HttpApiProblem
implements Serialize
and Deserialize
.
Examples
use *;
let p = new
.title
.detail
.type_url
.instance;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
There is also TryFrom<u16>
implemented for [StatusCode]:
use *;
let p = try_new.unwrap
.title
.detail
.type_url
.instance;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Features
Web Frameworks
There are multiple features to integrate with web frameworks:
warp
hyper
actix-web
salvo
tide
rocket
These mainly convert the HttpApiProblem
to response types of
the frameworks and implement traits to integrate with the frameworks
error handling
ApiError
The feature api-error
enables a structure which can be
return from "api handlers" that generate responses and can be
converted into an HttpApiProblem
.
Thank you
A big "thank you" for contributions and inspirations goes to the following GitHub users:
- panicbit
- thomaseizinger
- SohumB
License
http-api-problem
is primarily distributed under the terms of both the MIT
license and the Apache License (Version 2.0).
Copyright (c) 2017 Christian Douven.
License: Apache-2.0/MIT