sfr-server 0.1.2

The server implementation for a Slack App.
Documentation
//! The response for OAuth redirect.

use crate::response::{CT_TEXT_HTML, CT_TEXT_PLAIN};
use axum::body::Body;
use axum::http::Response;
use axum::response::IntoResponse;

/// The response for OAuth redirect.
#[derive(Debug)]
pub enum OauthRedirectResponse {
    /// The variant to return plain-text.
    Text(String),

    /// The variant to return HTML.
    Html(String),
}

impl OauthRedirectResponse {
    /// Creates [`Text`][`Self::Text`].
    pub fn text(inner: String) -> Self {
        Self::Text(inner)
    }

    /// Creates [`Html`][`Self::Html`].
    pub fn html(inner: String) -> Self {
        Self::Html(inner)
    }
}

impl IntoResponse for OauthRedirectResponse {
    fn into_response(self) -> Response<Body> {
        match self {
            Self::Text(inner) => ([CT_TEXT_PLAIN], inner).into_response(),

            Self::Html(inner) => ([CT_TEXT_HTML], inner).into_response(),
        }
    }
}