A library to create HTTP response content for APIs based on RFC7807.
This library depends on serde.
The HttpApiProblem
struct implements Serialize
and erialize`.
## Usage
Add this to your Cargo.toml
:
toml
http-api-problem = "0.1"
Add this crate root:
rust
extern crate http_api_problem;
## Example
```rust use httpapiproblem::*;
let p = HttpApiProblem::withtitleandtypefromstatus(428) .setdetail("detailed explanation") .set_instance("/on/1234/do/something");
asserteq!(Some("https://httpstatuses.com/428".tostring()), ypeurl); asserteq!(Some(428), p.status); asserteq!("Precondition Required".tostring(), p.title); asserteq!(Some("detailed explanation".tostring()), p.detail); asserteq!(Some("/on/1234/do/something".tostring()), 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.