2 comment::get_apub_comment,
5 get_apub_community_featured,
6 get_apub_community_followers,
7 get_apub_community_http,
8 get_apub_community_moderators,
9 get_apub_community_outbox,
12 person::{get_apub_person_http, get_apub_person_outbox, person_inbox},
15 site::{get_apub_site_http, get_apub_site_inbox, get_apub_site_outbox},
18 guard::{Guard, GuardContext},
19 http::{header, Method},
23 pub fn config(cfg: &mut web::ServiceConfig) {
25 .route("/", web::get().to(get_apub_site_http))
26 .route("/site_outbox", web::get().to(get_apub_site_outbox))
28 "/c/{community_name}",
29 web::get().to(get_apub_community_http),
32 "/c/{community_name}/followers",
33 web::get().to(get_apub_community_followers),
36 "/c/{community_name}/outbox",
37 web::get().to(get_apub_community_outbox),
40 "/c/{community_name}/featured",
41 web::get().to(get_apub_community_featured),
44 "/c/{community_name}/moderators",
45 web::get().to(get_apub_community_moderators),
47 .route("/u/{user_name}", web::get().to(get_apub_person_http))
49 "/u/{user_name}/outbox",
50 web::get().to(get_apub_person_outbox),
52 .route("/post/{post_id}", web::get().to(get_apub_post))
53 .route("/comment/{comment_id}", web::get().to(get_apub_comment))
54 .route("/activities/{type_}/{id}", web::get().to(get_activity));
58 .guard(InboxRequestGuard)
59 .route("/c/{community_name}/inbox", web::post().to(community_inbox))
60 .route("/u/{user_name}/inbox", web::post().to(person_inbox))
61 .route("/inbox", web::post().to(shared_inbox))
62 .route("/site_inbox", web::post().to(get_apub_site_inbox)),
66 /// Without this, things like webfinger or RSS feeds stop working, as all requests seem to get
67 /// routed into the inbox service (because it covers the root path). So we filter out anything that
68 /// definitely can't be an inbox request (based on Accept header and request method).
69 struct InboxRequestGuard;
71 impl Guard for InboxRequestGuard {
72 fn check(&self, ctx: &GuardContext) -> bool {
73 if ctx.head().method != Method::POST {
76 if let Some(val) = ctx.head().headers.get(header::CONTENT_TYPE) {
77 return val.as_bytes().starts_with(b"application/");