Merge pull request #330 from vbrandl/chore/update-actix-web2

Update actix-web and tokio
This commit is contained in:
Valentin Brandl 2021-09-03 13:20:09 +02:00 committed by GitHub
commit d37f5ba32b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 283 additions and 691 deletions

931
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -13,23 +13,23 @@ path = "src/main.rs"
name = "hoc"
[dependencies]
actix-rt = "1.1.1"
actix-web = "3.3.2"
actix-rt = "2.2.0"
actix-web = "4.0.0-beta.8"
badge = "0.3.0"
bytes = "1.1.0"
config = { version = "0.11.0", features = ["toml"] }
dotenv = "0.15.0"
futures = "0.3.15"
futures = "0.3.17"
git2 = "0.13.21"
lazy_static = "1.4.0"
number_prefix = "0.4.0"
openssl-probe = "0.1.4"
reqwest = "0.10.10"
reqwest = "0.11.4"
serde = "1.0.130"
serde_derive = "1.0.123"
serde_json = "1.0.67"
tracing = "0.1.26"
tracing-actix-web = "0.2.1"
tracing-actix-web = "0.4.0-beta.11"
tracing-bunyan-formatter = "0.2.5"
tracing-futures = "0.2.5"
tracing-log = "0.1.2"
@ -40,6 +40,7 @@ ructe = "0.13.4"
vergen = { version = "5.1.15", default-features = false, features = ["git"] }
[dev-dependencies]
awc = "3.0.0-beta.7"
ructe = "0.13.4"
tempfile = "3.2.0"
tokio = "0.2.25"
tokio = "1.11.0"

View File

@ -29,7 +29,7 @@ use crate::{
use actix_web::{
dev::Server,
http::header::{CacheControl, CacheDirective, Expires, LOCATION},
middleware::{self, normalize::TrailingSlash},
middleware::{self, TrailingSlash},
web, App, HttpResponse, HttpServer, Responder,
};
use badge::{Badge, BadgeOptions};
@ -224,10 +224,10 @@ where
})?;
repo_count.fetch_sub(1, Ordering::Relaxed);
Ok(HttpResponse::TemporaryRedirect()
.header(
.insert_header((
LOCATION,
format!("/{}/{}/{}/view", T::url_path(), data.0, data.1),
)
))
.finish())
};
future.instrument(span).await
@ -318,8 +318,8 @@ fn no_cache_response(body: Vec<u8>) -> HttpResponse {
let expiration = SystemTime::now() + Duration::from_secs(30);
HttpResponse::Ok()
.content_type("image/svg+xml")
.set(Expires(expiration.into()))
.set(CacheControl(vec![
.insert_header(Expires(expiration.into()))
.insert_header(CacheControl(vec![
CacheDirective::MaxAge(0u32),
CacheDirective::MustRevalidate,
CacheDirective::NoCache,
@ -480,7 +480,7 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
App::new()
.app_data(state.clone())
.app_data(repo_count.clone())
.wrap(tracing_actix_web::TracingLogger)
.wrap(tracing_actix_web::TracingLogger::default())
.wrap(middleware::NormalizePath::new(TrailingSlash::Trim))
.service(index)
.service(health_check)
@ -518,7 +518,7 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
.service(web::resource("/gitlab/{user}/{repo}/view").to(overview::<Gitlab>))
.service(web::resource("/bitbucket/{user}/{repo}/view").to(overview::<Bitbucket>))
.service(web::resource("/sourcehut/{user}/{repo}/view").to(overview::<Sourcehut>))
.default_service(web::resource("").route(web::get().to(async_p404)))
.default_service(web::to(async_p404))
})
.workers(workers)
.listen(listener)?

View File

@ -1,12 +1,10 @@
mod util;
use actix_web::client;
#[actix_rt::test]
async fn badge_succeeds() {
let test_app = util::spawn_app().await;
let client = client::Client::default();
let client = awc::Client::default();
let response = client
.get(&format!("{}/github/vbrandl/hoc", test_app.address))

View File

@ -1,12 +1,10 @@
mod util;
use actix_web::client;
#[actix_rt::test]
async fn health_check_works() {
let test_app = util::spawn_app().await;
let client = client::Client::default();
let client = awc::Client::default();
let response = client
.get(&format!("{}/health_check", test_app.address))

View File

@ -1,12 +1,10 @@
mod util;
use actix_web::client;
#[actix_rt::test]
async fn index_returns_success() {
let test_app = util::spawn_app().await;
let client = client::Client::default();
let client = awc::Client::default();
let response = client
.get(&format!("{}/", test_app.address))

View File

@ -1,12 +1,10 @@
mod util;
use actix_web::client;
#[actix_rt::test]
async fn json_returns_success() {
let test_app = util::spawn_app().await;
let client = client::Client::default();
let client = awc::Client::default();
let response = client
.get(&format!("{}/github/vbrandl/hoc/json", test_app.address))