Compare commits
5 commits
b0bb31bba0
...
5a746dd7b2
Author | SHA1 | Date | |
---|---|---|---|
5a746dd7b2 | |||
8ef530658f | |||
c0fb191581 | |||
0523e6c647 | |||
bdaa68e73f |
9 changed files with 71 additions and 4 deletions
|
@ -11,6 +11,7 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/acrate_rd/tests" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/acrate_rd/tests" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/acrate_mime/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/acrate_mime/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/acrate_rdserver/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/acrate_rdserver/src" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/acrate_apub_inbox/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/acrate_database/tests" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/acrate_database/tests" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["acrate_database", "acrate_rd", "acrate_nodeinfo", "acrate_rdserver"]
|
members = ["acrate_database", "acrate_rd", "acrate_nodeinfo", "acrate_rdserver", "acrate_apub_inbox"]
|
||||||
|
|
|
@ -27,6 +27,7 @@ Federation database
|
||||||
### Binaries
|
### Binaries
|
||||||
|
|
||||||
- `acrate_rdserver`: Resource descriptor web server
|
- `acrate_rdserver`: Resource descriptor web server
|
||||||
|
- `acrate_apub_inbox`: ActivityPub inbox web server
|
||||||
|
|
||||||
### Extra
|
### Extra
|
||||||
|
|
||||||
|
|
26
acrate_apub_inbox/Cargo.toml
Normal file
26
acrate_apub_inbox/Cargo.toml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
[package]
|
||||||
|
name = "acrate_apub_inbox"
|
||||||
|
version = "0.3.0"
|
||||||
|
authors = ["Stefano Pigozzi <me@steffo.eu>"]
|
||||||
|
edition = "2021"
|
||||||
|
description = "ActivityPub inbox web server for the acrate project"
|
||||||
|
repository = "https://forge.steffo.eu/unimore/tirocinio-canali-steffo-acrate"
|
||||||
|
license = "EUPL-1.2"
|
||||||
|
keywords = ["activitypub", "apub", "federation"]
|
||||||
|
categories = ["web-programming"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
acrate_database = { path = "../acrate_database", features = ["connect"] }
|
||||||
|
anyhow = "1.0.93"
|
||||||
|
axum = { version = "0.7.7", features = ["macros"] }
|
||||||
|
log = { version = "0.4.22", features = ["std", "max_level_trace", "release_max_level_debug"] }
|
||||||
|
micronfig = "0.3.0"
|
||||||
|
minijinja = "2.5.0"
|
||||||
|
pretty_env_logger = "0.5.0"
|
||||||
|
serde = { version = "1.0.215", features = ["derive"] }
|
||||||
|
serde_json = "1.0.132"
|
||||||
|
tokio = { version = "1.41.1", features = ["macros", "net", "rt-multi-thread"] }
|
||||||
|
mediatype = { version = "0.19.18", features = ["serde"] }
|
||||||
|
|
||||||
|
[lints.clippy]
|
||||||
|
tabs-in-doc-comments = "allow"
|
3
acrate_apub_inbox/src/config.rs
Normal file
3
acrate_apub_inbox/src/config.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
micronfig::config!(
|
||||||
|
ACRATE_APUB_INBOX_BIND_ADDRESS: String,
|
||||||
|
);
|
36
acrate_apub_inbox/src/main.rs
Normal file
36
acrate_apub_inbox/src/main.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use std::sync::Arc;
|
||||||
|
use anyhow::Context;
|
||||||
|
use axum::Extension;
|
||||||
|
|
||||||
|
mod config;
|
||||||
|
mod route;
|
||||||
|
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<std::convert::Infallible> {
|
||||||
|
pretty_env_logger::init();
|
||||||
|
log::debug!("Logging initialized!");
|
||||||
|
|
||||||
|
log::trace!("Creating Minijinja environment...");
|
||||||
|
let mut mj = minijinja::Environment::<'static>::new();
|
||||||
|
|
||||||
|
log::trace!("Creating Axum router...");
|
||||||
|
let app = axum::Router::new()
|
||||||
|
.layer(Extension(Arc::new(mj)));
|
||||||
|
log::trace!("Axum router created successfully!");
|
||||||
|
|
||||||
|
log::trace!("Creating Tokio listener...");
|
||||||
|
let bind_address = config::ACRATE_APUB_INBOX_BIND_ADDRESS();
|
||||||
|
let listener = tokio::net::TcpListener::bind(bind_address)
|
||||||
|
.await
|
||||||
|
.context("failed to bind listener to address")?;
|
||||||
|
log::trace!("Tokio listener bound to: {bind_address}");
|
||||||
|
|
||||||
|
log::info!("Starting apub_inbox web server...");
|
||||||
|
axum::serve(listener, app)
|
||||||
|
.await
|
||||||
|
.context("server exited with error")?;
|
||||||
|
|
||||||
|
log::error!("Server exited with no error, panicking.");
|
||||||
|
panic!("server exited with no error");
|
||||||
|
}
|
0
acrate_apub_inbox/src/route.rs
Normal file
0
acrate_apub_inbox/src/route.rs
Normal file
|
@ -1,3 +1,3 @@
|
||||||
micronfig::config!(
|
micronfig::config!(
|
||||||
ACRATE_WEBFINGER_BIND_ADDRESS: String,
|
ACRATE_RDSERVER_BIND_ADDRESS: String,
|
||||||
);
|
);
|
||||||
|
|
|
@ -26,13 +26,13 @@ async fn main() -> anyhow::Result<std::convert::Infallible> {
|
||||||
log::trace!("Axum router created successfully!");
|
log::trace!("Axum router created successfully!");
|
||||||
|
|
||||||
log::trace!("Creating Tokio listener...");
|
log::trace!("Creating Tokio listener...");
|
||||||
let bind_address = config::ACRATE_WEBFINGER_BIND_ADDRESS();
|
let bind_address = config::ACRATE_RDSERVER_BIND_ADDRESS();
|
||||||
let listener = tokio::net::TcpListener::bind(bind_address)
|
let listener = tokio::net::TcpListener::bind(bind_address)
|
||||||
.await
|
.await
|
||||||
.context("failed to bind listener to address")?;
|
.context("failed to bind listener to address")?;
|
||||||
log::trace!("Tokio listener bound to: {bind_address}");
|
log::trace!("Tokio listener bound to: {bind_address}");
|
||||||
|
|
||||||
log::info!("Starting server...");
|
log::info!("Starting rdserver web server...");
|
||||||
axum::serve(listener, app)
|
axum::serve(listener, app)
|
||||||
.await
|
.await
|
||||||
.context("server exited with error")?;
|
.context("server exited with error")?;
|
||||||
|
|
Loading…
Reference in a new issue