update dependencies and fix deprecations
This commit is contained in:
parent
165d68ca50
commit
b067be722d
866
Cargo.lock
generated
866
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -7,22 +7,32 @@ default-run = "terminwahl_back"
|
||||
|
||||
[dependencies]
|
||||
futures = "*"
|
||||
actix-web = "4.3"
|
||||
actix-web = "4.5"
|
||||
actix-rt = "2.8"
|
||||
actix-files = "0.6.2"
|
||||
actix-session = { version = "0.7", features = ["cookie-session"] }
|
||||
actix-session = { version = "0.9", features = ["cookie-session"] }
|
||||
# sqlx is currently on version 0.3.5 in this project due to breaking changes introduced in versions
|
||||
# beyond 0.4.0, which changed the return type of 'exectute' to a 'Done'. Also the row parsing related
|
||||
# traits have been altered. The overall architecture of this CRUD can still be reproduced with a
|
||||
# newer version of sqlx, and the version will be updated in the future.
|
||||
sqlx = { version = "0.6.2", features = ["sqlite", "runtime-actix-rustls", "chrono"] }
|
||||
sqlx = { version = "0.7", features = [
|
||||
"sqlite",
|
||||
"runtime-tokio-rustls",
|
||||
"chrono",
|
||||
] }
|
||||
uuid = { version = "1.2", features = ["serde", "v4"] }
|
||||
dotenv = "*"
|
||||
env_logger = "0.10"
|
||||
env_logger = "0.11"
|
||||
log = "*"
|
||||
lettre = {version="0.10", default-features = false, features = ["smtp-transport", "tokio1-rustls-tls", "hostname", "builder", "pool"]}
|
||||
lettre = { version = "0.11", default-features = false, features = [
|
||||
"smtp-transport",
|
||||
"tokio1-rustls-tls",
|
||||
"hostname",
|
||||
"builder",
|
||||
"pool",
|
||||
] }
|
||||
rand = "*"
|
||||
handlebars = {version="4.3", features=["dir_source"]}
|
||||
handlebars = { version = "5.1", features = ["dir_source"] }
|
||||
glob = "*"
|
||||
|
||||
terminwahl_typen = { path = "../terminwahl_typen/" }
|
||||
|
@ -1,26 +1,32 @@
|
||||
use actix_files::NamedFile;
|
||||
use actix_web::{dev, middleware::ErrorHandlerResponse, Result};
|
||||
use actix_web::{dev, middleware::ErrorHandlerResponse, Responder as _, Result};
|
||||
|
||||
pub fn bad_request<B>(res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
|
||||
let new_resp = NamedFile::open("static/errors/400.html")?
|
||||
.set_status_code(res.status())
|
||||
.into_response(res.request())
|
||||
.customize()
|
||||
.with_status(actix_web::http::StatusCode::OK)
|
||||
.respond_to(res.request())
|
||||
.map_into_boxed_body()
|
||||
.map_into_right_body();
|
||||
Ok(ErrorHandlerResponse::Response(res.into_response(new_resp)))
|
||||
}
|
||||
|
||||
pub fn not_found<B>(res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
|
||||
let new_resp = NamedFile::open("static/errors/404.html")?
|
||||
.set_status_code(res.status())
|
||||
.into_response(res.request())
|
||||
.customize()
|
||||
.with_status(actix_web::http::StatusCode::OK)
|
||||
.respond_to(res.request())
|
||||
.map_into_boxed_body()
|
||||
.map_into_right_body();
|
||||
Ok(ErrorHandlerResponse::Response(res.into_response(new_resp)))
|
||||
}
|
||||
|
||||
pub fn internal_server_error<B>(res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
|
||||
let new_resp = NamedFile::open("static/errors/500.html")?
|
||||
.set_status_code(res.status())
|
||||
.into_response(res.request())
|
||||
.customize()
|
||||
.with_status(actix_web::http::StatusCode::OK)
|
||||
.respond_to(res.request())
|
||||
.map_into_boxed_body()
|
||||
.map_into_right_body();
|
||||
Ok(ErrorHandlerResponse::Response(res.into_response(new_resp)))
|
||||
}
|
||||
|
55
terminwahl_back/src/api/errors_alt.rs
Normal file
55
terminwahl_back/src/api/errors_alt.rs
Normal file
@ -0,0 +1,55 @@
|
||||
use std::io::Read as _;
|
||||
|
||||
use actix_files::NamedFile;
|
||||
use actix_web::{
|
||||
body::MessageBody,
|
||||
dev::{self, ServiceResponse},
|
||||
middleware::ErrorHandlerResponse,
|
||||
Responder, Result,
|
||||
};
|
||||
|
||||
pub fn bad_request<B: MessageBody>(
|
||||
mut res: dev::ServiceResponse<B>,
|
||||
) -> Result<ErrorHandlerResponse<B>> {
|
||||
let mut new_resp = NamedFile::open("static/errors/400.html")?;
|
||||
let mut body = String::new();
|
||||
new_resp.read_to_string(&mut body);
|
||||
|
||||
res.response_mut().set_body(body);
|
||||
|
||||
/* let (req, res) = res.into_parts();
|
||||
res.set_body(body);
|
||||
|
||||
let response = ServiceResponse::new(req, res)
|
||||
.map_into_boxed_body()
|
||||
.map_into_right_body(); */
|
||||
|
||||
Ok(ErrorHandlerResponse::Response(
|
||||
res.map_into_boxed_body().map_into_right_body(),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn not_found<B>(res: dev::ServiceResponse<B>) -> Result<impl Responder> {
|
||||
let new_resp = NamedFile::open("static/errors/404.html")?
|
||||
.customize()
|
||||
.with_status(res.status())
|
||||
.respond_to(res.request());
|
||||
|
||||
Ok(new_resp)
|
||||
}
|
||||
|
||||
pub fn internal_server_error<B: MessageBody>(
|
||||
res: dev::ServiceResponse<B>,
|
||||
) -> Result<ErrorHandlerResponse<B>> {
|
||||
let mut new_resp = NamedFile::open("static/errors/500.html")?;
|
||||
let mut body = String::new();
|
||||
new_resp.read_to_string(&mut body);
|
||||
let (req, res) = res.into_parts();
|
||||
res.set_body(body);
|
||||
|
||||
let response = ServiceResponse::new(req, res)
|
||||
.map_into_boxed_body()
|
||||
.map_into_right_body();
|
||||
|
||||
Ok(ErrorHandlerResponse::Response(response))
|
||||
}
|
@ -7,11 +7,11 @@ use actix_web::{
|
||||
web, App, HttpServer,
|
||||
};
|
||||
use dotenv::dotenv;
|
||||
use handlebars::Handlebars;
|
||||
use handlebars::{DirectorySourceOptions, Handlebars};
|
||||
use lettre::{transport::smtp::authentication::Credentials, AsyncSmtpTransport, Tokio1Executor};
|
||||
use log::debug;
|
||||
use std::env;
|
||||
use terminwahl_back::{api, db, handlebars_helper::TimeOfDate, views, CssPath};
|
||||
use terminwahl_back::{api, db, views, CssPath};
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
@ -40,9 +40,12 @@ async fn main() -> std::io::Result<()> {
|
||||
.build();
|
||||
|
||||
let mut handlebars = Handlebars::new();
|
||||
handlebars.register_helper("time_of", Box::new(TimeOfDate));
|
||||
let handlebars_source = DirectorySourceOptions {
|
||||
tpl_extension: ".hbs".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
handlebars
|
||||
.register_templates_directory(".hbs", handlebars_templates)
|
||||
.register_templates_directory(handlebars_templates, handlebars_source)
|
||||
.unwrap();
|
||||
|
||||
log::info!("starting HTTP server at http://localhost:8080");
|
||||
|
@ -194,7 +194,7 @@ impl Component for App {
|
||||
<div class="section">
|
||||
{
|
||||
if let Some(dates) = self.dates.as_ref(){
|
||||
if let Some(date) = self.selected_date.as_ref(){
|
||||
if let Some(_date) = self.selected_date.as_ref(){
|
||||
if let Some(_saved) = self.successfully_saved.as_ref(){
|
||||
self.view_dank_dialog(ctx)
|
||||
} else if self.nutzer.is_none(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user