Compare commits
3 commits
cef5e8c19b
...
8552052a46
Author | SHA1 | Date | |
---|---|---|---|
8552052a46 | |||
30610df0f5 | |||
c427af8186 |
6 changed files with 53 additions and 9 deletions
|
@ -9,6 +9,7 @@ quick-xml = { version = "0.37.0", features = ["overlapped-lists", "serialize"] }
|
||||||
reqwest = { version = "0.12.9", features = ["json", "stream"] }
|
reqwest = { version = "0.12.9", features = ["json", "stream"] }
|
||||||
serde = { version = "1.0.214", features = ["derive"] }
|
serde = { version = "1.0.214", features = ["derive"] }
|
||||||
serde_json = "1.0.132"
|
serde_json = "1.0.132"
|
||||||
|
thiserror = "2.0.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_env_logger = "0.5.0"
|
pretty_env_logger = "0.5.0"
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
/// A resource descriptor object.
|
/// A resource descriptor object.
|
||||||
///
|
///
|
||||||
|
@ -477,19 +478,22 @@ impl ResourceDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error occurred during [`ResourceDescriptor::discover`].
|
/// Error occurred during [`ResourceDescriptor::discover`].
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
pub enum ResourceDescriptorDiscoveryError {
|
pub enum ResourceDescriptorDiscoveryError {
|
||||||
/// Manipulation of the provided base [`reqwest::Url`] failed.
|
/// Manipulation of the provided base [`reqwest::Url`] failed.
|
||||||
///
|
///
|
||||||
/// See [reqwest::Url::set_scheme] for possible causes.
|
/// See [reqwest::Url::set_scheme] for possible causes.
|
||||||
|
#[error("manipulation of the provided URL failed")]
|
||||||
UrlManipulation(()),
|
UrlManipulation(()),
|
||||||
|
|
||||||
/// All attempts of fetching a resource descriptor document failed.
|
/// All attempts of fetching a resource descriptor document failed.
|
||||||
|
#[error("fetchign the resource descriptor document failed")]
|
||||||
Fetch(ResourceDescriptorDiscoveryFailures),
|
Fetch(ResourceDescriptorDiscoveryFailures),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request errors occurred during [`ResourceDescriptor::discover`].
|
/// Request errors occurred during [`ResourceDescriptor::discover`].
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
|
#[error("all attempts of fetching the resource descriptor document failed")]
|
||||||
pub struct ResourceDescriptorDiscoveryFailures {
|
pub struct ResourceDescriptorDiscoveryFailures {
|
||||||
/// HTTPS XRD retrieval.
|
/// HTTPS XRD retrieval.
|
||||||
pub https_xrd: GetXRDError,
|
pub https_xrd: GetXRDError,
|
||||||
|
@ -511,30 +515,46 @@ pub struct ResourceDescriptorDiscoveryFailures {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error occurred during [`ResourceDescriptor::get_xrd`].
|
/// Error occurred during [`ResourceDescriptor::get_xrd`].
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
pub enum GetXRDError {
|
pub enum GetXRDError {
|
||||||
/// The HTTP request failed.
|
/// The HTTP request failed.
|
||||||
|
#[error("the HTTP request failed")]
|
||||||
Request(reqwest::Error),
|
Request(reqwest::Error),
|
||||||
|
|
||||||
/// The `Content-Type` header of the response is missing.
|
/// The `Content-Type` header of the response is missing.
|
||||||
|
#[error("the Content-Type header of the response is missing")]
|
||||||
ContentTypeMissing,
|
ContentTypeMissing,
|
||||||
|
|
||||||
/// The `Content-Type` header of the response is invalid.
|
/// The `Content-Type` header of the response is invalid.
|
||||||
|
#[error("the Content-Type header of the response is invalid")]
|
||||||
ContentTypeInvalid,
|
ContentTypeInvalid,
|
||||||
/// The document failed to be read as text.
|
|
||||||
|
/// The document failed to be decoded as text.
|
||||||
|
#[error("the document failed to be decoded as text")]
|
||||||
Decode(reqwest::Error),
|
Decode(reqwest::Error),
|
||||||
|
|
||||||
/// The document failed to be parsed as XML by [`quick_xml`].
|
/// The document failed to be parsed as XML by [`quick_xml`].
|
||||||
|
#[error("the document failed to be parsed as XML")]
|
||||||
Parse(quick_xml::DeError),
|
Parse(quick_xml::DeError),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error occurred during [`ResourceDescriptor::get_jrd`].
|
/// Error occurred during [`ResourceDescriptor::get_jrd`].
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
pub enum GetJRDError {
|
pub enum GetJRDError {
|
||||||
/// The HTTP request failed.
|
/// The HTTP request failed.
|
||||||
|
#[error("the HTTP request failed")]
|
||||||
Request(reqwest::Error),
|
Request(reqwest::Error),
|
||||||
|
|
||||||
/// The `Content-Type` header of the response is missing.
|
/// The `Content-Type` header of the response is missing.
|
||||||
|
#[error("the Content-Type header of the response is missing")]
|
||||||
ContentTypeMissing,
|
ContentTypeMissing,
|
||||||
|
|
||||||
/// The `Content-Type` header of the response is invalid.
|
/// The `Content-Type` header of the response is invalid.
|
||||||
|
#[error("the Content-Type header of the response is invalid")]
|
||||||
ContentTypeInvalid,
|
ContentTypeInvalid,
|
||||||
|
|
||||||
/// The document failed to be parsed as JSON by [`reqwest`].
|
/// The document failed to be parsed as JSON by [`reqwest`].
|
||||||
|
#[error("the document failed to be parsed as JSON")]
|
||||||
Parse(reqwest::Error),
|
Parse(reqwest::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
|
mod route;
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -9,7 +10,8 @@ async fn main() -> anyhow::Result<std::convert::Infallible> {
|
||||||
log::debug!("Logging initialized!");
|
log::debug!("Logging initialized!");
|
||||||
|
|
||||||
log::trace!("Creating Axum router...");
|
log::trace!("Creating Axum router...");
|
||||||
let app = axum::Router::new();
|
let app = axum::Router::new()
|
||||||
|
.route("/inbox", axum::routing::post(route::inbox_handler));
|
||||||
log::trace!("Axum router created successfully!");
|
log::trace!("Axum router created successfully!");
|
||||||
|
|
||||||
log::trace!("Creating Tokio listener...");
|
log::trace!("Creating Tokio listener...");
|
||||||
|
|
8
acrate-inbox/src/route.rs
Normal file
8
acrate-inbox/src/route.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#[allow(unreachable_code)]
|
||||||
|
pub async fn inbox_handler() {
|
||||||
|
todo!("pre-validation hook");
|
||||||
|
todo!("validate signature");
|
||||||
|
todo!("post-validation hook");
|
||||||
|
todo!("database storage");
|
||||||
|
todo!("post-storage hook");
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ log = "0.4.22"
|
||||||
reqwest = { version = "0.12.9", features = ["json", "stream"] }
|
reqwest = { version = "0.12.9", features = ["json", "stream"] }
|
||||||
serde = { version = "1.0.214", features = ["derive"] }
|
serde = { version = "1.0.214", features = ["derive"] }
|
||||||
serde_json = "1.0.132"
|
serde_json = "1.0.132"
|
||||||
|
thiserror = "2.0.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_env_logger = "0.5.0"
|
pretty_env_logger = "0.5.0"
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
//! - <https://codeberg.org/fediverse/fep/src/branch/main/fep/f1d5/fep-f1d5.md>
|
//! - <https://codeberg.org/fediverse/fep/src/branch/main/fep/f1d5/fep-f1d5.md>
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
/// A variant of a NodeInfo document.
|
/// A variant of a NodeInfo document.
|
||||||
///
|
///
|
||||||
|
@ -309,11 +310,13 @@ impl NodeInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error occurred during [`NodeInfo::get_latest_wellknown`].
|
/// An error occurred during [`NodeInfo::get_latest_wellknown`].
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
pub enum NodeInfoGetWellknownError {
|
pub enum NodeInfoGetWellknownError {
|
||||||
/// The discovery of possible locations for NodeInfo documents failed.
|
/// The discovery of possible locations for NodeInfo documents failed.
|
||||||
|
#[error("the discovery of possible locations for NodeInfo documents failed")]
|
||||||
Discovery(acrate_hostmeta::ResourceDescriptorDiscoveryError),
|
Discovery(acrate_hostmeta::ResourceDescriptorDiscoveryError),
|
||||||
/// No compatible NodeInfo documents were detected at the given URL.
|
/// No compatible NodeInfo documents were detected at the given URL.
|
||||||
|
#[error("no compatible NodeInfo documents were detected at the given URL")]
|
||||||
Unsupported,
|
Unsupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,17 +449,26 @@ impl NodeInfo2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error encountered during [`NodeInfo1::get`] or [`NodeInfo2::get`].
|
/// An error encountered during [`NodeInfo1::get`] or [`NodeInfo2::get`].
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Error)]
|
||||||
pub enum NodeInfoGetError {
|
pub enum NodeInfoGetError {
|
||||||
/// The HTTP request failed.
|
/// The HTTP request failed.
|
||||||
|
#[error("the HTTP request failed")]
|
||||||
Request(reqwest::Error),
|
Request(reqwest::Error),
|
||||||
|
|
||||||
/// The `Content-Type` header of the response is missing.
|
/// The `Content-Type` header of the response is missing.
|
||||||
|
#[error("the Content-Type header of the response is missing")]
|
||||||
ContentTypeMissing,
|
ContentTypeMissing,
|
||||||
|
|
||||||
/// The `Content-Type` header of the response is invalid.
|
/// The `Content-Type` header of the response is invalid.
|
||||||
|
#[error("the Content-Type header of the response is invalid")]
|
||||||
ContentTypeInvalid,
|
ContentTypeInvalid,
|
||||||
|
|
||||||
/// The document failed to be parsed as JSON by [`reqwest`].
|
/// The document failed to be parsed as JSON by [`reqwest`].
|
||||||
|
#[error("the document failed to be parsed as JSON")]
|
||||||
Parse(reqwest::Error),
|
Parse(reqwest::Error),
|
||||||
/// The returned version does not match the version of the created struct.
|
|
||||||
|
/// The returned NodeInfo version would not match the version of the called method.
|
||||||
|
#[error("the returned NodeInfo version would not match the version of the called method")]
|
||||||
Version,
|
Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue