Skip to content

Commit

Permalink
Merge pull request 'Also return json for long accept header with prof…
Browse files Browse the repository at this point in the history
…ile link (ref #1216)' (#114) from json-headers into main

Reviewed-on: https://yerbamate.dev/LemmyNet/lemmy/pulls/114
  • Loading branch information
dessalines committed Oct 21, 2020
2 parents dd99e77 + e8379cb commit 3e22c99
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/routes/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@ use lemmy_apub::{
use lemmy_utils::settings::Settings;
use sha2::{Digest, Sha256};

static APUB_JSON_CONTENT_TYPE_LONG: &str =
"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"";

pub fn config(cfg: &mut web::ServiceConfig) {
if Settings::get().federation.enabled {
println!("federation enabled, host is {}", Settings::get().hostname);
let digest_verifier = VerifyDigest::new(Sha256::new());

let header_guard = guard::Any(guard::Header("Accept", APUB_JSON_CONTENT_TYPE))
.or(guard::Header("Accept", APUB_JSON_CONTENT_TYPE_LONG));

cfg
.service(
web::scope("/")
.guard(guard::Header("Accept", APUB_JSON_CONTENT_TYPE))
.guard(header_guard)
.route(
"/c/{community_name}",
web::get().to(get_apub_community_http),
Expand Down

0 comments on commit 3e22c99

Please sign in to comment.