From b388c10aeab97181825b892a6792e440880d6055 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 18 Feb 2022 02:13:08 +0000 Subject: [PATCH] fix links --- Cargo.lock | 2 ++ forms/multipart-s3/Cargo.toml | 9 ++++++--- forms/multipart-s3/README.md | 6 +++--- forms/multipart-s3/src/main.rs | 33 ++++++++++++++++++--------------- server-sent-events/README.md | 4 ++-- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9212b4d..7540cea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3320,7 +3320,9 @@ dependencies = [ "actix-multipart", "actix-web", "dotenv", + "env_logger", "futures", + "log", "rusoto_core", "rusoto_s3", "sanitize-filename", diff --git a/forms/multipart-s3/Cargo.toml b/forms/multipart-s3/Cargo.toml index b6056ee..3faba42 100644 --- a/forms/multipart-s3/Cargo.toml +++ b/forms/multipart-s3/Cargo.toml @@ -6,10 +6,13 @@ edition = "2021" [dependencies] actix-web = "4.0.0-rc.1" actix-multipart = "0.4.0-beta.12" + +dotenv = "0.15.0" +env_logger = "0.9" futures = "0.3.1" -rusoto_s3 = "0.47.0" +log = "0.4" rusoto_core = "0.47.0" +rusoto_s3 = "0.47.0" +sanitize-filename = "0.3" serde = { version = "1.0.104", features = ["derive"] } serde_json = "1.0" -dotenv = "0.15.0" -sanitize-filename = "0.3" diff --git a/forms/multipart-s3/README.md b/forms/multipart-s3/README.md index e501962..7af5452 100644 --- a/forms/multipart-s3/README.md +++ b/forms/multipart-s3/README.md @@ -17,9 +17,9 @@ cd forms/multipart-s3 cd forms/multipart-s3 cargo run (or ``cargo watch -x run``) ``` -http://localhost:3000 +http://localhost:3000 # using other regions -https://www.rusoto.org/regions.html -https://docs.rs/rusoto_core/0.42.0/rusoto_core/enum.Region.html +- https://www.rusoto.org/regions.html +- https://docs.rs/rusoto_core/0.42.0/rusoto_core/enum.Region.html diff --git a/forms/multipart-s3/src/main.rs b/forms/multipart-s3/src/main.rs index ecf6d4b..ff3edab 100644 --- a/forms/multipart-s3/src/main.rs +++ b/forms/multipart-s3/src/main.rs @@ -1,12 +1,12 @@ +use std::{borrow::BorrowMut, env}; + use actix_multipart::Multipart; -use actix_web::{middleware, web, App, Error, HttpResponse, HttpServer}; +use actix_web::{middleware::Logger, web, App, Error, HttpResponse, HttpServer}; use dotenv::dotenv; use serde::{Deserialize, Serialize}; -use std::borrow::BorrowMut; -use std::env; -use utils::upload::{save_file as upload_save_file, split_payload, UploadFile}; mod utils; +use self::utils::upload::{save_file as upload_save_file, split_payload, UploadFile}; #[derive(Deserialize, Serialize, Debug)] pub struct InpAdd { @@ -77,6 +77,8 @@ async fn index() -> HttpResponse { #[actix_web::main] async fn main() -> std::io::Result<()> { dotenv().ok(); + env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); + let aws_access_key_id = env::var("AWS_ACCESS_KEY_ID").expect("AWS_ACCESS_KEY_ID must be set"); let aws_secret_access_key = @@ -84,23 +86,24 @@ async fn main() -> std::io::Result<()> { let aws_s3_bucket_name = env::var("AWS_S3_BUCKET_NAME").expect("AWS_S3_BUCKET_NAME must be set"); - println!("{}", aws_access_key_id); - println!("{}", aws_secret_access_key); - println!("{}", aws_s3_bucket_name); + log::info!("aws_access_key_id: {}", aws_access_key_id); + log::info!("aws_secret_access_key: {}", aws_secret_access_key); + log::info!("aws_s3_bucket_name: {}", aws_s3_bucket_name); - std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info"); std::fs::create_dir_all("./tmp").unwrap(); - let ip = "0.0.0.0:3000"; + log::info!("starting HTTP server at http://localhost:8080"); HttpServer::new(|| { - App::new().wrap(middleware::Logger::default()).service( - web::resource("/") - .route(web::get().to(index)) - .route(web::post().to(save_file)), - ) + App::new() + .service( + web::resource("/") + .route(web::get().to(index)) + .route(web::post().to(save_file)), + ) + .wrap(Logger::default()) }) - .bind(ip)? + .bind(("127.0.0.1", 8080))? .run() .await } diff --git a/server-sent-events/README.md b/server-sent-events/README.md index aa627ae..e14d6f8 100644 --- a/server-sent-events/README.md +++ b/server-sent-events/README.md @@ -17,7 +17,7 @@ curl 127.0.0.1:8080/broadcast/my_message ## Performance This implementation can serve thousands of clients on a 2021 MacBook with no problems. -Run [benchmark.js](benchmark.js) to benchmark your own system: +Run `node ./benchmark.js` to benchmark your own system: ```sh $ node benchmark.js @@ -31,7 +31,7 @@ You may be limited to a maximal number of connections (open file descriptors). S ulimit -n 2048 ``` -Test maximum number of open connections with [drain.js](drain.js): +Test maximum number of open connections with `node ./drain.js`: ```sh $ node drain.js