Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Switch warp to axum framework
Browse files Browse the repository at this point in the history
  • Loading branch information
tommymalmqvist committed Nov 3, 2022
1 parent f208c06 commit 9a24c39
Show file tree
Hide file tree
Showing 26 changed files with 374 additions and 1,246 deletions.
31 changes: 15 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,25 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rust-ocpp = "0.2.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
chrono = { version = "0.4.19", features = ["serde"] }
rand = "0.8"
async-trait = "0.1.42"
strum = "0.24.0"
strum_macros = "0.24.0"
uuid = { version = "0.8", features = ["v4"] }
futures = { version = "0.3" }
tokio = { version = "1", features = ["full"] }
log = "0.4"
rust-ocpp = "0.2.2"
axum = { version = "0.6.0-rc.2", features = ["ws", "headers"] }
headers = "0.3"
tokio = { version = "1.0", features = ["full"] }
tower-http = { version = "0.3.0", features = ["fs", "trace"] }
tower = "0.4.8"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0.66"
pretty_env_logger = "0.4.0"
warp = { version = "0.3", features = ["tls"] }
strum_macros = "0.24.3"

[dev-dependencies]
mockall = "0.11.0"
mockall = "0.11.3"

[[bin]]
name = "ws"
name = "csms"
test = false
bench = false
path = "src/main.rs"
path = "src/main.rs"
9 changes: 4 additions & 5 deletions src/authorization/authorize.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use crate::handlers::response::handle_response;
use crate::rpc::enums::AuthorizeKind;
use futures::stream::SplitSink;
use warp::ws::{Message, WebSocket};
use axum::extract::ws::Message;

pub async fn handle_authorize(request: AuthorizeKind, tx: &mut SplitSink<WebSocket, Message>) {
pub async fn handle_authorize(request: AuthorizeKind) {
match request {
AuthorizeKind::Request(req) => {
handle_response(Message::text(serde_json::to_string(&req).unwrap()), tx).await;
handle_response(Message::Text(serde_json::to_string(&req).unwrap())).await;
}
_ => {
handle_response(Message::text("Got response"), tx).await;
handle_response(Message::Text("Got response".into())).await;
}
}
}
1 change: 0 additions & 1 deletion src/availability/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/certificate_management/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/data_transfer/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/diagnostics/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/display_message/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/firmware_management/mod.rs

This file was deleted.

28 changes: 0 additions & 28 deletions src/handlers/connection.rs

This file was deleted.

19 changes: 4 additions & 15 deletions src/handlers/error.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
use futures::stream::SplitSink;
use futures::SinkExt;
use axum::extract::ws::Message;
use pretty_env_logger;
use tracing::info;

use log::error;
use log::info;
use warp::ws::{Message, WebSocket};

pub async fn handle_error(error: Message, tx: &mut SplitSink<WebSocket, Message>) {
pub async fn handle_error(error: Message) {
info!("Entered error_handler");
match tx.send(error).await {
Ok(_) => (),
Err(e) => {
error!(
"websocket error: Could not send error response. Error: ({})",
e
);
}
}
}
Loading

0 comments on commit 9a24c39

Please sign in to comment.