rings-node 1.0.0-pre.8

Rings is a browser-native, structured peer-to-peer network: browser tabs and native daemons find each other by DID and talk over WebRTC, routed by a Chord DHT.
Documentation
use axum::http::StatusCode;
use axum::response::IntoResponse;
use axum::response::Response;

#[derive(Debug)]
pub enum HttpError {
    BadRequest,
    Internal,
}

impl IntoResponse for HttpError {
    fn into_response(self) -> Response {
        let (code, msg) = match self {
            HttpError::BadRequest => (StatusCode::BAD_REQUEST, "Bad Request"),
            HttpError::Internal => (StatusCode::INTERNAL_SERVER_ERROR, "Internal error"),
        };

        (code, msg).into_response()
    }
}

impl From<axum::http::Error> for HttpError {
    fn from(_: axum::http::Error) -> Self {
        HttpError::Internal
    }
}

impl From<anyhow::Error> for HttpError {
    fn from(_: anyhow::Error) -> Self {
        HttpError::Internal
    }
}