Update to stable actix-web

This commit is contained in:
Aode (Lion) 2022-02-26 12:12:07 -06:00
parent b331d47f23
commit f9816ddd3b
4 changed files with 362 additions and 237 deletions

566
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
[package] [package]
name = "ap-relay" name = "ap-relay"
description = "A simple activitypub relay" description = "A simple activitypub relay"
version = "0.3.18" version = "0.3.19"
authors = ["asonix <asonix@asonix.dog>"] authors = ["asonix <asonix@asonix.dog>"]
license-file = "LICENSE" license-file = "LICENSE"
readme = "README.md" readme = "README.md"
@ -23,17 +23,17 @@ default = []
[dependencies] [dependencies]
anyhow = "1.0" anyhow = "1.0"
actix-rt = "2.6.0" actix-rt = "2.6.0"
actix-web = { version = "4.0.0-rc.3", default-features = false } actix-web = { version = "4.0.1", default-features = false }
actix-webfinger = "0.4.0-beta.5" actix-webfinger = "0.4.0-beta.5"
activitystreams = "0.7.0-alpha.16" activitystreams = "0.7.0-alpha.19"
activitystreams-ext = "0.1.0-alpha.2" activitystreams-ext = "0.1.0-alpha.2"
ammonia = "3.1.0" ammonia = "3.1.0"
async-rwlock = "1.3.0" async-rwlock = "1.3.0"
awc = { version = "3.0.0-beta.20", default-features = false, features = [ awc = { version = "3.0.0-beta.21", default-features = false, features = [
"rustls", "rustls",
] } ] }
base64 = "0.13" base64 = "0.13"
config = "0.11.0" config = "0.12.0"
console-subscriber = { version = "0.1", optional = true } console-subscriber = { version = "0.1", optional = true }
dashmap = "5.1.0" dashmap = "5.1.0"
dotenv = "0.15.0" dotenv = "0.15.0"
@ -48,7 +48,7 @@ rsa-magic-public-key = "0.4.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
sha2 = "0.10" sha2 = "0.10"
sled = "0.34.6" sled = "0.34.7"
structopt = "0.3.12" structopt = "0.3.12"
thiserror = "1.0" thiserror = "1.0"
tracing = "0.1" tracing = "0.1"
@ -70,12 +70,12 @@ default-features = false
features = ["background-jobs-actix", "error-logging"] features = ["background-jobs-actix", "error-logging"]
[dependencies.http-signature-normalization-actix] [dependencies.http-signature-normalization-actix]
version = "0.6.0-beta.5" version = "0.6.0-beta.6"
default-features = false default-features = false
features = ["client", "server", "sha-2"] features = ["client", "server", "sha-2"]
[dependencies.tracing-actix-web] [dependencies.tracing-actix-web]
version = "0.5.0-rc.3" version = "0.5.0"
[build-dependencies] [build-dependencies]
anyhow = "1.0" anyhow = "1.0"

View file

@ -84,11 +84,10 @@ impl std::fmt::Debug for Config {
impl Config { impl Config {
pub(crate) fn build() -> Result<Self, Error> { pub(crate) fn build() -> Result<Self, Error> {
let mut config = config::Config::new(); let config = config::Config::builder()
config
.set_default("hostname", "localhost:8080")? .set_default("hostname", "localhost:8080")?
.set_default("addr", "127.0.0.1")? .set_default("addr", "127.0.0.1")?
.set_default("port", 8080)? .set_default::<_, u64>("port", 8080)?
.set_default("debug", true)? .set_default("debug", true)?
.set_default("restricted_mode", false)? .set_default("restricted_mode", false)?
.set_default("validate_signatures", false)? .set_default("validate_signatures", false)?
@ -97,9 +96,10 @@ impl Config {
.set_default("sled_path", "./sled/db-0-34")? .set_default("sled_path", "./sled/db-0-34")?
.set_default("source_repo", "https://git.asonix.dog/asonix/relay")? .set_default("source_repo", "https://git.asonix.dog/asonix/relay")?
.set_default("opentelemetry_url", None as Option<&str>)? .set_default("opentelemetry_url", None as Option<&str>)?
.merge(Environment::new())?; .add_source(Environment::default())
.build()?;
let config: ParsedConfig = config.try_into()?; let config: ParsedConfig = config.try_deserialize()?;
let scheme = if config.https { "https" } else { "http" }; let scheme = if config.https { "https" } else { "http" };
let base_uri = iri!(format!("{}://{}", scheme, config.hostname)).into_absolute(); let base_uri = iri!(format!("{}://{}", scheme, config.hostname)).into_absolute();

View file

@ -1,4 +1,5 @@
use activitystreams::checked::CheckError; use activitystreams::checked::CheckError;
use actix_rt::task::JoinError;
use actix_web::{ use actix_web::{
error::{BlockingError, ResponseError}, error::{BlockingError, ResponseError},
http::StatusCode, http::StatusCode,
@ -193,6 +194,12 @@ impl From<BlockingError> for ErrorKind {
} }
} }
impl From<JoinError> for ErrorKind {
fn from(_: JoinError) -> Self {
ErrorKind::Canceled
}
}
impl From<Infallible> for ErrorKind { impl From<Infallible> for ErrorKind {
fn from(i: Infallible) -> Self { fn from(i: Infallible) -> Self {
match i {} match i {}