mirror of
https://github.com/actix/examples
synced 2024-11-23 22:41:07 +01:00
chore: update deps
This commit is contained in:
parent
dca1d50430
commit
697d2ec49d
1170
Cargo.lock
generated
1170
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -113,6 +113,7 @@ rustls = "0.23"
|
|||||||
rustls-pemfile = "2"
|
rustls-pemfile = "2"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
time = "0.3"
|
||||||
tokio = { version = "1.24.2", features = ["sync", "io-util"] }
|
tokio = { version = "1.24.2", features = ["sync", "io-util"] }
|
||||||
tokio-util = "0.7.4"
|
tokio-util = "0.7.4"
|
||||||
tokio-stream = "0.1.1"
|
tokio-stream = "0.1.1"
|
||||||
|
@ -14,4 +14,4 @@ serde_json.workspace = true
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-test.workspace = true
|
actix-test.workspace = true
|
||||||
time = "0.3"
|
time.workspace = true
|
||||||
|
@ -20,5 +20,5 @@ rust-argon2 = "2"
|
|||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
sparkpost = "0.5"
|
sparkpost = "0.5"
|
||||||
time = "0.3"
|
time.workspace = true
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
|
@ -6,11 +6,12 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web.workspace = true
|
actix-web.workspace = true
|
||||||
|
|
||||||
anyhow = "1"
|
|
||||||
apalis = { version = "0.4", features = ["redis"] }
|
apalis = { version = "0.4", features = ["redis"] }
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
|
color-eyre.workspace = true
|
||||||
dotenvy.workspace = true
|
dotenvy.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
|
eyre.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
rand.workspace = true
|
rand.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
@ -14,7 +14,8 @@ mod routes;
|
|||||||
pub(crate) type ItemCache = Mutex<HashMap<String, DateTime<Utc>>>;
|
pub(crate) type ItemCache = Mutex<HashMap<String, DateTime<Utc>>>;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> eyre::Result<()> {
|
||||||
|
color_eyre::install()?;
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use apalis::{prelude::*, redis::RedisStorage};
|
use apalis::{prelude::*, redis::RedisStorage};
|
||||||
use rand::Rng as _;
|
use rand::distributions::{Alphanumeric, DistString as _};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -13,14 +13,8 @@ pub(crate) struct Email {
|
|||||||
|
|
||||||
impl Email {
|
impl Email {
|
||||||
pub(crate) fn random() -> Self {
|
pub(crate) fn random() -> Self {
|
||||||
let user = (&mut rand::thread_rng())
|
let user = Alphanumeric.sample_string(&mut rand::thread_rng(), 10);
|
||||||
.sample_iter(rand::distributions::Alphanumeric)
|
|
||||||
.take(10)
|
|
||||||
.map(char::from)
|
|
||||||
.collect::<String>();
|
|
||||||
|
|
||||||
let to = format!("{user}@fake-mail.com");
|
let to = format!("{user}@fake-mail.com");
|
||||||
|
|
||||||
Self { to }
|
Self { to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,7 +32,7 @@ async fn process_email_job(job: Email, _ctx: JobContext) -> Result<(), JobError>
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn start_processing_email_queue() -> anyhow::Result<RedisStorage<Email>> {
|
pub(crate) async fn start_processing_email_queue() -> eyre::Result<RedisStorage<Email>> {
|
||||||
let redis_url = std::env::var("REDIS_URL").expect("Missing env variable REDIS_URL");
|
let redis_url = std::env::var("REDIS_URL").expect("Missing env variable REDIS_URL");
|
||||||
let storage = RedisStorage::connect(redis_url).await?;
|
let storage = RedisStorage::connect(redis_url).await?;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||||||
actix-files.workspace = true
|
actix-files.workspace = true
|
||||||
actix-session = { workspace = true, features = ["cookie-session"] }
|
actix-session = { workspace = true, features = ["cookie-session"] }
|
||||||
actix-web.workspace = true
|
actix-web.workspace = true
|
||||||
|
actix-web-lab.workspace = true
|
||||||
|
|
||||||
async-stream = "0.3"
|
async-stream = "0.3"
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
|
@ -10,6 +10,7 @@ use actix_web::{
|
|||||||
},
|
},
|
||||||
middleware, web, App, Either, HttpRequest, HttpResponse, HttpServer, Responder, Result,
|
middleware, web, App, Either, HttpRequest, HttpResponse, HttpServer, Responder, Result,
|
||||||
};
|
};
|
||||||
|
use actix_web_lab::extract::Path;
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
|
|
||||||
// NOTE: Not a suitable session key for production.
|
// NOTE: Not a suitable session key for production.
|
||||||
@ -54,8 +55,7 @@ async fn default_handler(req_method: Method) -> Result<impl Responder> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// response body
|
async fn streaming_response(path: web::Path<String>) -> HttpResponse {
|
||||||
async fn response_body(path: web::Path<String>) -> HttpResponse {
|
|
||||||
let name = path.into_inner();
|
let name = path.into_inner();
|
||||||
|
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
@ -67,13 +67,13 @@ async fn response_body(path: web::Path<String>) -> HttpResponse {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// handler with path parameters like `/user/{name}/`
|
/// handler with path parameters like `/user/{name}`
|
||||||
async fn with_param(req: HttpRequest, path: web::Path<(String,)>) -> HttpResponse {
|
async fn with_param(req: HttpRequest, Path((name,)): Path<(String,)>) -> HttpResponse {
|
||||||
println!("{req:?}");
|
println!("{req:?}");
|
||||||
|
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
.content_type(ContentType::plaintext())
|
.content_type(ContentType::plaintext())
|
||||||
.body(format!("Hello {}!", path.0))
|
.body(format!("Hello {name}!"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
@ -104,7 +104,7 @@ async fn main() -> io::Result<()> {
|
|||||||
// with path parameters
|
// with path parameters
|
||||||
.service(web::resource("/user/{name}").route(web::get().to(with_param)))
|
.service(web::resource("/user/{name}").route(web::get().to(with_param)))
|
||||||
// async response body
|
// async response body
|
||||||
.service(web::resource("/async-body/{name}").route(web::get().to(response_body)))
|
.service(web::resource("/async-body/{name}").route(web::get().to(streaming_response)))
|
||||||
.service(
|
.service(
|
||||||
web::resource("/test").to(|req: HttpRequest| match *req.method() {
|
web::resource("/test").to(|req: HttpRequest| match *req.method() {
|
||||||
Method::GET => HttpResponse::Ok(),
|
Method::GET => HttpResponse::Ok(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "error_handling"
|
name = "error-handling"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ edition.workspace = true
|
|||||||
acme-rfc8555 = "0.1"
|
acme-rfc8555 = "0.1"
|
||||||
actix-files.workspace = true
|
actix-files.workspace = true
|
||||||
actix-web = { workspace = true, features = ["rustls-0_23"] }
|
actix-web = { workspace = true, features = ["rustls-0_23"] }
|
||||||
color-eyre = "0.6"
|
color-eyre.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
eyre = "0.6"
|
eyre.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
rustls.workspace = true
|
rustls.workspace = true
|
||||||
rustls-pemfile.workspace = true
|
rustls-pemfile.workspace = true
|
||||||
|
@ -4,11 +4,6 @@ version = "1.0.0"
|
|||||||
publish = false
|
publish = false
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[package.metadata.cargo-machete]
|
|
||||||
ignored = [
|
|
||||||
"yarte_helpers", # only build dep
|
|
||||||
]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web.workspace = true
|
actix-web.workspace = true
|
||||||
derive_more.workspace = true
|
derive_more.workspace = true
|
||||||
@ -16,7 +11,5 @@ env_logger.workspace = true
|
|||||||
log.workspace = true
|
log.workspace = true
|
||||||
yarte = { version = "0.15", features = ["bytes-buf", "html-min"] }
|
yarte = { version = "0.15", features = ["bytes-buf", "html-min"] }
|
||||||
|
|
||||||
[build-dependencies.yarte_helpers]
|
[build-dependencies]
|
||||||
version = "0.15.6"
|
yarte_helpers = { version = "0.15", default-features = false, features = ["config"] }
|
||||||
default-features = false
|
|
||||||
features = ["config"]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user