Skip to main content

Crate mockeroo_mock_responses

Crate mockeroo_mock_responses 

Source
Expand description

Sarcastic HTTP status code responses for testing and development.

Mirrors the behaviour of the @mockeroo/mock-responses npm package.

§Example

use mockeroo_mock_responses::{get_response, get_available_codes};

if let Some(resp) = get_response(404) {
    println!("{} — {}", resp.status, resp.message);
}

let codes = get_available_codes();
println!("Supported codes: {:?}", codes);

Structs§

Response
An HTTP status code paired with a randomly chosen sarcastic message.

Functions§

get_available_codes
Returns all supported HTTP status codes in ascending order.
get_response
Returns a Response with a random sarcastic message for the given HTTP status code, or None if the code is not recognised.