# HTTP-API-PROBLEM
[](https://crates.io/crates/http-api-problem)
[](https://docs.rs/http-api-problem)
[](https://crates.io/crates/http-api-problem)
[](https://travis-ci.org/chridou/http-api-problem)
[](https://github.com/chridou/http-api-problem/blob/master/LICENSE-MIT)
[](https://github.com/chridou/http-api-problem/blob/master/LICENSE-APACHE)
A library to create HTTP response content for APIs based on [RFC7807](https://tools.ietf.org/html/rfc7807).
This library depends on [serde](https://serde.rs/).
The `HttpApiProblem` struct implements `Serialize` and `Deserialize`.
## Usage
Get the latest version for your `Cargo.toml` from
[crates.io](https://crates.io/crates/http-api-problem).
Add this to your crate root:
```rust
extern crate http_api_problem;
```
## Example
```rust
use http_api_problem::*;
let p =
HttpApiProblem::with_title_and_type_from_status(428)
.set_detail("detailed explanation")
.set_instance("/on/1234/do/something");
assert_eq!(Some("https://httpstatuses.com/428".to_string()), ype_url);
assert_eq!(Some(428), p.status);
assert_eq!("Precondition Required".to_string(), p.title);
assert_eq!(Some("detailed explanation".to_string()), p.detail);
assert_eq!(Some("/on/1234/do/something".to_string()), nstance);
```
## License
`http-api-problem` is primarily distributed under the terms of h the MIT license and the
Apache License (Version 2.0).
Copyright (c) 2017 Christian Douven.