A library to create HTTP response content for APIs based on RFC7807
This library depends on serde.
The HttpApiProblem
struct implements `Serialize'.
The documentation can be found on docs.rs
Add this to your Cargo.toml
:
toml
http-api-problem = { version="0.1.0" }
Add this crate root:
rust
extern crate http_api_problem;
```rust use httpapiproblem::*;
let p = HttpApiProblem::withtypeandtitlefromstatus(428) .setdetail("detailed explanation") .set_instance("/on/1234/do/something");
asserteq!("https://httpstatuses.com/428", p.typeurl); asserteq!(Some(428), p.status); asserteq!(Some("Precondition Required".tostring()), p.title); asserteq!(Some("detailed explanation".tostring()), p.detail); asserteq!(Some("/on/1234/do/something".to_string()), p.instance); ```
http-api-problem
is primarily distributed under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2017 Christian Douven.