about summary refs log tree commit diff
path: root/kittybox-rs/indieauth
diff options
context:
space:
mode:
Diffstat (limited to 'kittybox-rs/indieauth')
-rw-r--r--kittybox-rs/indieauth/src/lib.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/kittybox-rs/indieauth/src/lib.rs b/kittybox-rs/indieauth/src/lib.rs
index cb99146..5896ebb 100644
--- a/kittybox-rs/indieauth/src/lib.rs
+++ b/kittybox-rs/indieauth/src/lib.rs
@@ -85,6 +85,18 @@ pub struct Profile {
     pub email: Option<String>
 }
 
+#[cfg(feature = "axum")]
+impl axum_core::response::IntoResponse for Profile {
+    fn into_response(self) -> axum_core::response::Response {
+        use http::StatusCode;
+
+        (StatusCode::OK,
+         [("Content-Type", "application/json")],
+         serde_json::to_vec(&self).unwrap())
+            .into_response()
+    }
+}
+
 #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
 pub struct State(String);
 impl State {
@@ -157,6 +169,21 @@ pub enum GrantResponse {
     }
 }
 
+#[cfg(feature = "axum")]
+impl axum_core::response::IntoResponse for GrantResponse {
+    fn into_response(self) -> axum_core::response::Response {
+        use http::StatusCode;
+
+        (StatusCode::OK,
+         [("Content-Type", "application/json"),
+          ("Cache-Control", "no-store"),
+          ("Pragma", "no-cache")
+         ],
+         serde_json::to_vec(&self).unwrap())
+            .into_response()
+    }
+}
+
 /// Describes requests that the authorization endpoint might want to handle.
 ///
 /// This type mostly exists for ease-of-use with serde.
@@ -257,6 +284,19 @@ impl From<TokenIntrospectionResponse> for Option<TokenData> {
     }
 }
 
+#[cfg(feature = "axum")]
+impl axum_core::response::IntoResponse for TokenIntrospectionResponse {
+    fn into_response(self) -> axum_core::response::Response {
+        use http::StatusCode;
+
+        (StatusCode::OK,
+         [("Content-Type", "application/json")],
+         serde_json::to_vec(&self).unwrap())
+            .into_response()
+    }
+}
+
+
 #[derive(Debug, Serialize, Deserialize)]
 pub struct TokenRevocationRequest {
     pub token: String