diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 2746e9a..4ac96f8 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -225,7 +225,7 @@ dependencies = [ [[package]] name = "actix-web" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "actix-codec 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -269,7 +269,7 @@ dependencies = [ "actix 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-codec 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2147,8 +2147,7 @@ version = "0.2.1" dependencies = [ "actix 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-http 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-rt 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "actix-web 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "actix-web 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2744,7 +2743,7 @@ dependencies = [ "checksum actix-threadpool 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d209f04d002854b9afd3743032a27b066158817965bf5d036824d19ac2cc0e30" "checksum actix-tls 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24789b7d7361cf5503a504ebe1c10806896f61e96eca9a7350e23001aca715fb" "checksum actix-utils 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9022dec56632d1d7979e59af14f0597a28a830a9c1c7fec8b2327eb9f16b5a" -"checksum actix-web 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cd7fc56022da91a4dc00ccae7d7bb82e539749ca36df181695f4efdf5d413b2e" +"checksum actix-web 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "36de80175eb1f0a5c518024ce0d23646b54a23008279e090ca1848f6f1448bf4" "checksum actix-web-actors 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f6edf3c2693e2a8c422800c87ee89a6a4eac7dd01109bc172a1093ce1f4f001" "checksum actix-web-codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "750ca8fb60bbdc79491991650ba5d2ae7cd75f3fc00ead51390cfe9efda0d4d8" "checksum actix_derive 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b95aceadaf327f18f0df5962fedc1bde2f870566a0b9f65c89508a3b1f79334c" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 6f70a4f..0ea3f6d 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -7,8 +7,7 @@ license = "GPL-3.0" [dependencies] actix = "0.10.0" -actix-rt = "1.1.1" -actix-web = "3.0.1" +actix-web = "3.0.2" actix-web-actors = "3.0.0" actix-http = "2.0.0" bytes = "0.5.6" diff --git a/backend/src/main.rs b/backend/src/main.rs index 8310cf2..b590c2a 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -2,7 +2,7 @@ use std::net::Ipv4Addr; use actix::prelude::*; use actix_http::ws::Codec; -use actix_web::{web, App, Error, HttpRequest, HttpResponse, HttpServer}; +use actix_web::{web, get, middleware, App, Error, HttpRequest, HttpResponse, HttpServer}; use actix_web_actors::ws; use clap::Clap; use simple_logger::SimpleLogger; @@ -38,6 +38,7 @@ struct Opts { } /// Entry point for connecting nodes +#[get("/submit/")] async fn node_route( req: HttpRequest, stream: web::Payload, @@ -63,6 +64,7 @@ async fn node_route( } /// Entry point for connecting feeds +#[get("/feed/")] async fn feed_route( req: HttpRequest, stream: web::Payload, @@ -76,6 +78,7 @@ async fn feed_route( } /// Entry point for network state dump +#[get("/network_state/{chain}/{nid}/")] async fn state_route( path: web::Path<(Box, NodeId)>, aggregator: web::Data>, @@ -104,6 +107,7 @@ async fn state_route( } /// Entry point for health check monitoring bots +#[get("/health/")] async fn health(aggregator: web::Data>) -> Result { match aggregator.send(GetHealth).await { Ok(count) => { @@ -121,10 +125,8 @@ async fn health(aggregator: web::Data>) -> Result std::io::Result<()> { - use web::{get, resource}; - SimpleLogger::new().with_level(log::LevelFilter::Info).init().expect("Must be able to start a logger"); let opts: Opts = Opts::parse(); @@ -134,16 +136,13 @@ async fn main() -> std::io::Result<()> { HttpServer::new(move || { App::new() + .wrap(middleware::NormalizePath::default()) .data(aggregator.clone()) .data(locator.clone()) - .service(resource("/submit").route(get().to(node_route))) - .service(resource("/submit/").route(get().to(node_route))) - .service(resource("/feed").route(get().to(feed_route))) - .service(resource("/feed/").route(get().to(feed_route))) - .service(resource("/network_state/{chain}/{nid}").route(get().to(state_route))) - .service(resource("/network_state/{chain}/{nid}/").route(get().to(state_route))) - .service(resource("/health").route(get().to(health))) - .service(resource("/health/").route(get().to(health))) + .service(node_route) + .service(feed_route) + .service(state_route) + .service(health) }) .bind(format!("{}", opts.socket))? .run()