httproxide 0.2.0

Rusted HTTP router reverse-proxy
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use axum::handler::HandlerWithoutStateExt;
use http::StatusCode;

use crate::target::{IntoTarget, Target};

pub fn default_body_for_status(code: &StatusCode) -> String {
    let mut text = code.as_u16().to_string();
    if let Some(reason) = code.canonical_reason() {
        text = format!("{} {}", text, reason);
    }
    text
}

pub fn get_error_responder(code: StatusCode) -> Target {
    let text = default_body_for_status(&code);
    let service = (move || async move { (code, text) }).into_service();
    IntoTarget::into_target(service)
}