diff --git a/src/routes/activitypub/application.rs b/src/routes/activitypub/application.rs index d3e01ad..57510cc 100644 --- a/src/routes/activitypub/application.rs +++ b/src/routes/activitypub/application.rs @@ -1,12 +1,22 @@ use apb::{ActorMut, BaseMut, ObjectMut, PublicKeyMut}; -use axum::{extract::State, http::StatusCode}; +use axum::{extract::State, http::HeaderMap, response::{IntoResponse, Redirect, Response}}; use crate::{server::Context, url}; use super::{jsonld::LD, JsonLD}; -pub async fn view(State(ctx): State) -> Result, StatusCode> { +pub async fn view( + headers: HeaderMap, + State(ctx): State, +) -> crate::Result { + if let Some(accept) = headers.get("Accept") { + if let Ok(accept) = accept.to_str() { + if accept.contains("text/html") { + return Ok(Redirect::to("/web").into_response()); + } + } + } Ok(JsonLD( serde_json::Value::new_object() .set_id(Some(&url!(ctx, ""))) @@ -23,5 +33,5 @@ pub async fn view(State(ctx): State) -> Result