sfr_server/response/
oauth.rs

1//! The response for OAuth redirect.
2
3use crate::response::{CT_TEXT_HTML, CT_TEXT_PLAIN};
4use axum::body::Body;
5use axum::http::Response;
6use axum::response::IntoResponse;
7
8/// The response for OAuth redirect.
9#[derive(Debug)]
10pub enum OauthRedirectResponse {
11    /// The variant to return plain-text.
12    Text(String),
13
14    /// The variant to return HTML.
15    Html(String),
16}
17
18impl OauthRedirectResponse {
19    /// Creates [`Text`][`Self::Text`].
20    pub fn text(inner: String) -> Self {
21        Self::Text(inner)
22    }
23
24    /// Creates [`Html`][`Self::Html`].
25    pub fn html(inner: String) -> Self {
26        Self::Html(inner)
27    }
28}
29
30impl IntoResponse for OauthRedirectResponse {
31    fn into_response(self) -> Response<Body> {
32        match self {
33            Self::Text(inner) => ([CT_TEXT_PLAIN], inner).into_response(),
34
35            Self::Html(inner) => ([CT_TEXT_HTML], inner).into_response(),
36        }
37    }
38}