mirror of
https://github.com/actix/examples
synced 2024-11-23 22:41:07 +01:00
update actix-web-lab dep
This commit is contained in:
parent
0c820844c8
commit
ca6eaee52e
30
Cargo.lock
generated
30
Cargo.lock
generated
@ -504,11 +504,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "actix-web-lab"
|
||||
version = "0.18.9"
|
||||
version = "0.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55b7ac6309cfb46949171c49f7bc81d021310205a39bf0b0d0465e80a4857e3c"
|
||||
checksum = "9e9f49571dfcf49ed79c6e7a645e9554ae01925eb55fa6e3b2501ceeed24d7e7"
|
||||
dependencies = [
|
||||
"actix-files",
|
||||
"actix-http",
|
||||
"actix-router",
|
||||
"actix-service",
|
||||
@ -534,7 +533,6 @@ dependencies = [
|
||||
"pin-project-lite 0.2.9",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_cbor_2",
|
||||
"serde_html_form",
|
||||
"serde_json",
|
||||
"tokio 1.26.0",
|
||||
@ -543,9 +541,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "actix-web-lab-derive"
|
||||
version = "0.18.0"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4419acd7924ac473ccd00a6efea324dd382b0b7ae31b8e06cd2c58d4d7afae6"
|
||||
checksum = "16294584c7794939b1e5711f28e7cae84ef30e62a520db3f9af425f85269bcd2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -3386,12 +3384,6 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "1.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||
|
||||
[[package]]
|
||||
name = "handlebars"
|
||||
version = "4.3.6"
|
||||
@ -6324,16 +6316,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_cbor_2"
|
||||
version = "0.12.0-dev"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b46d75f449e01f1eddbe9b00f432d616fbbd899b809c837d0fbc380496a0dd55"
|
||||
dependencies = [
|
||||
"half",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.155"
|
||||
@ -6347,9 +6329,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_html_form"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d051fb33111db0e81673ed8c55db741952a19ad81dc584960c8aec836498ba5"
|
||||
checksum = "53192e38d5c88564b924dbe9b60865ecbb71b81d38c4e61c817cffd3e36ef696"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"indexmap",
|
||||
|
@ -83,7 +83,7 @@ actix-tls = "3"
|
||||
actix-utils = "3"
|
||||
actix-web = "4.3"
|
||||
actix-web-actors = "4.1"
|
||||
actix-web-lab = "0.18"
|
||||
actix-web-lab = "0.19"
|
||||
actix-ws = "0.2.5"
|
||||
awc = "3"
|
||||
|
||||
|
@ -6,7 +6,6 @@ use actix_web::{
|
||||
http::StatusCode,
|
||||
middleware, web, App, HttpMessage as _, HttpRequest, HttpServer, Responder,
|
||||
};
|
||||
use actix_web_lab::web::Redirect;
|
||||
|
||||
const ONE_MINUTE: Duration = Duration::minutes(1);
|
||||
|
||||
@ -23,13 +22,13 @@ async fn index(identity: Option<Identity>) -> actix_web::Result<impl Responder>
|
||||
async fn login(req: HttpRequest) -> impl Responder {
|
||||
Identity::login(&req.extensions(), "user1".to_owned()).unwrap();
|
||||
|
||||
Redirect::to("/").using_status_code(StatusCode::FOUND)
|
||||
web::Redirect::to("/").using_status_code(StatusCode::FOUND)
|
||||
}
|
||||
|
||||
async fn logout(id: Identity) -> impl Responder {
|
||||
id.logout();
|
||||
|
||||
Redirect::to("/").using_status_code(StatusCode::FOUND)
|
||||
web::Redirect::to("/").using_status_code(StatusCode::FOUND)
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
|
@ -1,10 +1,9 @@
|
||||
use actix_files::NamedFile;
|
||||
use actix_session::Session;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::{
|
||||
dev, error, middleware::ErrorHandlerResponse, web, Error, HttpResponse, Responder, Result,
|
||||
dev, error, http::StatusCode, middleware::ErrorHandlerResponse, web, Error, HttpResponse,
|
||||
Responder, Result,
|
||||
};
|
||||
use actix_web_lab::web::Redirect;
|
||||
use serde::Deserialize;
|
||||
use sqlx::SqlitePool;
|
||||
use tera::{Context, Tera};
|
||||
@ -51,7 +50,7 @@ pub async fn create(
|
||||
) -> Result<impl Responder, Error> {
|
||||
if params.description.is_empty() {
|
||||
session::set_flash(&session, FlashMessage::error("Description cannot be empty"))?;
|
||||
Ok(Redirect::to("/").using_status_code(StatusCode::FOUND))
|
||||
Ok(web::Redirect::to("/").using_status_code(StatusCode::FOUND))
|
||||
} else {
|
||||
db::create_task(params.into_inner().description, &pool)
|
||||
.await
|
||||
@ -59,7 +58,7 @@ pub async fn create(
|
||||
|
||||
session::set_flash(&session, FlashMessage::success("Task successfully added"))?;
|
||||
|
||||
Ok(Redirect::to("/").using_status_code(StatusCode::FOUND))
|
||||
Ok(web::Redirect::to("/").using_status_code(StatusCode::FOUND))
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +78,7 @@ pub async fn update(
|
||||
form: web::Form<UpdateForm>,
|
||||
session: Session,
|
||||
) -> Result<impl Responder, Error> {
|
||||
Ok(Redirect::to(match form._method.as_ref() {
|
||||
Ok(web::Redirect::to(match form._method.as_ref() {
|
||||
"put" => toggle(db, params).await?,
|
||||
"delete" => delete(db, params, session).await?,
|
||||
unsupported_method => {
|
||||
|
@ -4,7 +4,6 @@ use actix_files::Files;
|
||||
use actix_web::{
|
||||
http::header::ContentType, middleware, web, App, HttpRequest, HttpResponse, HttpServer,
|
||||
};
|
||||
use actix_web_lab::web::redirect;
|
||||
use log::debug;
|
||||
use rustls::{Certificate, PrivateKey, ServerConfig};
|
||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||
@ -34,7 +33,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.wrap(middleware::Logger::default())
|
||||
// register simple handler, handle all methods
|
||||
.service(web::resource("/index.html").to(index))
|
||||
.service(redirect("/", "/index.html"))
|
||||
.service(web::redirect("/", "/index.html"))
|
||||
.service(Files::new("/static", "static"))
|
||||
})
|
||||
.bind_rustls("127.0.0.1:8443", config)?
|
||||
|
@ -1,7 +1,6 @@
|
||||
use actix_utils::future::{ready, Ready};
|
||||
use minijinja_autoreload::AutoReloader;
|
||||
use std::{collections::HashMap, env, path::PathBuf};
|
||||
|
||||
use actix_utils::future::{ready, Ready};
|
||||
use actix_web::{
|
||||
dev::{self, ServiceResponse},
|
||||
error,
|
||||
@ -10,6 +9,7 @@ use actix_web::{
|
||||
web, App, FromRequest, HttpRequest, HttpResponse, HttpServer, Responder, Result,
|
||||
};
|
||||
use actix_web_lab::respond::Html;
|
||||
use minijinja_autoreload::AutoReloader;
|
||||
|
||||
struct MiniJinjaRenderer {
|
||||
tmpl_env: web::Data<minijinja_autoreload::AutoReloader>,
|
||||
|
Loading…
Reference in New Issue
Block a user