Update backend code to Rust Edition 2024
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use actix_identity::Identity;
|
||||
use std::future::{ready, Ready};
|
||||
use std::future::{Ready, ready};
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::app_config::AppConfig;
|
||||
@ -7,8 +7,8 @@ use crate::constants;
|
||||
use actix_web::body::EitherBody;
|
||||
use actix_web::dev::Payload;
|
||||
use actix_web::{
|
||||
dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform},
|
||||
Error, FromRequest, HttpResponse,
|
||||
dev::{Service, ServiceRequest, ServiceResponse, Transform, forward_ready},
|
||||
};
|
||||
use futures_util::future::LocalBoxFuture;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use actix_web::HttpResponse;
|
||||
use actix_web::body::BoxBody;
|
||||
use actix_web::http::StatusCode;
|
||||
use actix_web::HttpResponse;
|
||||
use std::error::Error;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::io::ErrorKind;
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::logs::logs_manager;
|
||||
use crate::logs::severity::LogSeverity;
|
||||
use crate::server::WebEnergyActor;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::devices_api::jwt_parser::JWTRequest;
|
||||
use crate::server::WebEnergyActor;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct LogRequest {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::ota::ota_manager;
|
||||
use crate::ota::ota_update::OTAPlatform;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct FirmwarePath {
|
||||
|
@ -4,10 +4,10 @@ use crate::energy::energy_actor;
|
||||
use crate::energy::energy_actor::RelaySyncStatus;
|
||||
use crate::ota::ota_manager;
|
||||
use crate::ota::ota_update::OTAPlatform;
|
||||
use crate::server::WebEnergyActor;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::devices_api::jwt_parser::JWTRequest;
|
||||
use crate::server::WebEnergyActor;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use actix_web::{HttpResponse, web};
|
||||
use openssl::nid::Nid;
|
||||
use openssl::x509::X509Req;
|
||||
use std::str::FromStr;
|
||||
|
@ -10,14 +10,14 @@ use crate::server::unsecure_server::*;
|
||||
use crate::server::web_api::*;
|
||||
use crate::server::web_app_controller;
|
||||
use actix_cors::Cors;
|
||||
use actix_identity::config::LogoutBehaviour;
|
||||
use actix_identity::IdentityMiddleware;
|
||||
use actix_identity::config::LogoutBehaviour;
|
||||
use actix_remote_ip::RemoteIPConfig;
|
||||
use actix_session::storage::CookieSessionStore;
|
||||
use actix_session::SessionMiddleware;
|
||||
use actix_session::storage::CookieSessionStore;
|
||||
use actix_web::cookie::{Key, SameSite};
|
||||
use actix_web::middleware::Logger;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use actix_web::{App, HttpServer, web};
|
||||
use openssl::ssl::{SslAcceptor, SslMethod};
|
||||
use std::time::Duration;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::app_config::AppConfig;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct ServeCRLPath {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::devices::device::DeviceRelayID;
|
||||
use crate::energy::{energy_actor, relay_state_history};
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::WebEnergyActor;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct LegacyStateRelay {
|
||||
|
@ -2,7 +2,7 @@ use crate::app_config::AppConfig;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_identity::Identity;
|
||||
use actix_remote_ip::RemoteIP;
|
||||
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse};
|
||||
use actix_web::{HttpMessage, HttpRequest, HttpResponse, web};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct AuthRequest {
|
||||
@ -17,11 +17,11 @@ pub async fn password_auth(
|
||||
remote_ip: RemoteIP,
|
||||
) -> HttpResult {
|
||||
if r.user != AppConfig::get().admin_username || r.password != AppConfig::get().admin_password {
|
||||
log::error!("Failed login attempt from {}!", remote_ip.0.to_string());
|
||||
log::error!("Failed login attempt from {}!", remote_ip.0);
|
||||
return Ok(HttpResponse::Unauthorized().json("Invalid credentials!"));
|
||||
}
|
||||
|
||||
log::info!("Successful login attempt from {}!", remote_ip.0.to_string());
|
||||
log::info!("Successful login attempt from {}!", remote_ip.0);
|
||||
Identity::login(&request.extensions(), r.user.to_string())?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::devices::device::{DeviceGeneralInfo, DeviceId};
|
||||
use crate::energy::energy_actor;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::WebEnergyActor;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
/// Get the list of pending (not accepted yet) devices
|
||||
pub async fn list_pending(actor: WebEnergyActor) -> HttpResult {
|
||||
|
@ -2,8 +2,8 @@ use crate::app_config::ConsumptionHistoryType;
|
||||
use crate::energy::consumption::EnergyConsumption;
|
||||
use crate::energy::consumption_history_file::ConsumptionHistoryFile;
|
||||
use crate::energy::{consumption, energy_actor};
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::WebEnergyActor;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::utils::time_utils::time_secs;
|
||||
use actix_web::HttpResponse;
|
||||
|
||||
|
@ -3,7 +3,7 @@ use crate::logs::logs_manager;
|
||||
use crate::logs::severity::LogSeverity;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::utils::time_utils::curr_day_number;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct LogRequest {
|
||||
|
@ -3,11 +3,11 @@ use crate::devices::device::DeviceId;
|
||||
use crate::energy::energy_actor;
|
||||
use crate::ota::ota_manager;
|
||||
use crate::ota::ota_update::OTAPlatform;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::WebEnergyActor;
|
||||
use actix_multipart::form::tempfile::TempFile;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_multipart::form::MultipartForm;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use actix_multipart::form::tempfile::TempFile;
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
pub async fn supported_platforms() -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(OTAPlatform::supported_platforms()))
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::devices::device::{DeviceId, DeviceRelay, DeviceRelayID};
|
||||
use crate::energy::energy_actor;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::WebEnergyActor;
|
||||
use actix_web::{web, HttpResponse};
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
/// Get the full list of relays
|
||||
pub async fn get_list(actor: WebEnergyActor) -> HttpResult {
|
||||
|
@ -19,7 +19,7 @@ mod serve_static_debug {
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
mod serve_static_release {
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use actix_web::{HttpResponse, Responder, web};
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
#[derive(RustEmbed)]
|
||||
|
Reference in New Issue
Block a user