1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00

fix links

This commit is contained in:
Rob Ede 2022-02-18 02:13:08 +00:00
parent 74ee6ae707
commit b388c10aea
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
5 changed files with 31 additions and 23 deletions

2
Cargo.lock generated
View File

@ -3320,7 +3320,9 @@ dependencies = [
"actix-multipart",
"actix-web",
"dotenv",
"env_logger",
"futures",
"log",
"rusoto_core",
"rusoto_s3",
"sanitize-filename",

View File

@ -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"

View File

@ -21,5 +21,5 @@ 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

View File

@ -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(
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
}

View File

@ -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