Skip to main content

actpub_axum/
lib.rs

1//! [axum] 0.8 integration for `actpub-federation`.
2//!
3//! Drop-in router builders that wire the federation runtime into an
4//! existing axum service:
5//!
6//! - [`inbox_router`] — POST endpoint dispatching to a configured
7//!   [`InboxPipeline`](actpub_federation::InboxPipeline).
8//! - [`webfinger_router`] — `/.well-known/webfinger` endpoint resolving
9//!   `acct:` URIs via a user-supplied callback.
10//! - [`nodeinfo_router`] — `/.well-known/nodeinfo` discovery + per-version
11//!   schema endpoints.
12//! - [`FederationJson<T>`] responder — serialises `T` with the
13//!   `application/activity+json` media type required by every Fediverse
14//!   peer.
15//!
16//! Each router is a standalone [`Router`](axum::Router) that mounts at
17//! its conventional path; compose them via
18//! [`Router::merge`](axum::Router::merge) to build a complete service.
19//!
20//! [axum]: https://docs.rs/axum
21#![cfg_attr(docsrs, feature(doc_cfg))]
22#![allow(
23    clippy::module_name_repetitions,
24    reason = "router builder names like `inbox_router` mirror the conventional naming pattern axum users expect"
25)]
26#![cfg_attr(
27    test,
28    allow(
29        clippy::indexing_slicing,
30        clippy::panic,
31        clippy::unwrap_used,
32        reason = "JSON / byte indexing is ergonomic in tests, and `panic!` / `unwrap()` are the idiomatic way to assert expectations"
33    )
34)]
35
36mod inbox;
37mod json;
38mod nodeinfo;
39mod webfinger;
40
41use bytes as _;
42use http as _;
43use serde as _;
44use serde_json as _;
45use thiserror as _;
46use tower as _;
47use tower_http as _;
48use tracing as _;
49use url as _;
50#[cfg(test)]
51use {actpub_httpsig as _, http_body_util as _, httpdate as _, pretty_assertions as _};
52
53pub use self::inbox::{DEFAULT_MAX_INBOX_BYTES, InboxState, inbox_router};
54pub use self::json::{ACTIVITY_PUB_CONTENT_TYPE, FederationJson};
55pub use self::nodeinfo::{NODEINFO_CONTENT_TYPE, NodeInfoState, nodeinfo_router};
56pub use self::webfinger::{JRD_CONTENT_TYPE, WebFingerResolver, webfinger_router};