mirror of
https://github.com/actix/examples
synced 2024-11-23 22:41:07 +01:00
fix links
This commit is contained in:
parent
74ee6ae707
commit
b388c10aea
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -3320,7 +3320,9 @@ dependencies = [
|
|||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
"env_logger",
|
||||||
"futures",
|
"futures",
|
||||||
|
"log",
|
||||||
"rusoto_core",
|
"rusoto_core",
|
||||||
"rusoto_s3",
|
"rusoto_s3",
|
||||||
"sanitize-filename",
|
"sanitize-filename",
|
||||||
|
@ -6,10 +6,13 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.0.0-rc.1"
|
actix-web = "4.0.0-rc.1"
|
||||||
actix-multipart = "0.4.0-beta.12"
|
actix-multipart = "0.4.0-beta.12"
|
||||||
|
|
||||||
|
dotenv = "0.15.0"
|
||||||
|
env_logger = "0.9"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
rusoto_s3 = "0.47.0"
|
log = "0.4"
|
||||||
rusoto_core = "0.47.0"
|
rusoto_core = "0.47.0"
|
||||||
|
rusoto_s3 = "0.47.0"
|
||||||
|
sanitize-filename = "0.3"
|
||||||
serde = { version = "1.0.104", features = ["derive"] }
|
serde = { version = "1.0.104", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
dotenv = "0.15.0"
|
|
||||||
sanitize-filename = "0.3"
|
|
||||||
|
@ -17,9 +17,9 @@ cd forms/multipart-s3
|
|||||||
cd forms/multipart-s3
|
cd forms/multipart-s3
|
||||||
cargo run (or ``cargo watch -x run``)
|
cargo run (or ``cargo watch -x run``)
|
||||||
```
|
```
|
||||||
http://localhost:3000
|
http://localhost:3000
|
||||||
|
|
||||||
|
|
||||||
# using other regions
|
# using other regions
|
||||||
https://www.rusoto.org/regions.html
|
- https://www.rusoto.org/regions.html
|
||||||
https://docs.rs/rusoto_core/0.42.0/rusoto_core/enum.Region.html
|
- https://docs.rs/rusoto_core/0.42.0/rusoto_core/enum.Region.html
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
use std::{borrow::BorrowMut, env};
|
||||||
|
|
||||||
use actix_multipart::Multipart;
|
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 dotenv::dotenv;
|
||||||
use serde::{Deserialize, Serialize};
|
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;
|
mod utils;
|
||||||
|
use self::utils::upload::{save_file as upload_save_file, split_payload, UploadFile};
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug)]
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
pub struct InpAdd {
|
pub struct InpAdd {
|
||||||
@ -77,6 +77,8 @@ async fn index() -> HttpResponse {
|
|||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
|
|
||||||
let aws_access_key_id =
|
let aws_access_key_id =
|
||||||
env::var("AWS_ACCESS_KEY_ID").expect("AWS_ACCESS_KEY_ID must be set");
|
env::var("AWS_ACCESS_KEY_ID").expect("AWS_ACCESS_KEY_ID must be set");
|
||||||
let aws_secret_access_key =
|
let aws_secret_access_key =
|
||||||
@ -84,23 +86,24 @@ async fn main() -> std::io::Result<()> {
|
|||||||
let aws_s3_bucket_name =
|
let aws_s3_bucket_name =
|
||||||
env::var("AWS_S3_BUCKET_NAME").expect("AWS_S3_BUCKET_NAME must be set");
|
env::var("AWS_S3_BUCKET_NAME").expect("AWS_S3_BUCKET_NAME must be set");
|
||||||
|
|
||||||
println!("{}", aws_access_key_id);
|
log::info!("aws_access_key_id: {}", aws_access_key_id);
|
||||||
println!("{}", aws_secret_access_key);
|
log::info!("aws_secret_access_key: {}", aws_secret_access_key);
|
||||||
println!("{}", aws_s3_bucket_name);
|
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();
|
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(|| {
|
HttpServer::new(|| {
|
||||||
App::new().wrap(middleware::Logger::default()).service(
|
App::new()
|
||||||
web::resource("/")
|
.service(
|
||||||
.route(web::get().to(index))
|
web::resource("/")
|
||||||
.route(web::post().to(save_file)),
|
.route(web::get().to(index))
|
||||||
)
|
.route(web::post().to(save_file)),
|
||||||
|
)
|
||||||
|
.wrap(Logger::default())
|
||||||
})
|
})
|
||||||
.bind(ip)?
|
.bind(("127.0.0.1", 8080))?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ curl 127.0.0.1:8080/broadcast/my_message
|
|||||||
## Performance
|
## Performance
|
||||||
This implementation can serve thousands of clients on a 2021 MacBook with no problems.
|
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
|
```sh
|
||||||
$ node benchmark.js
|
$ node benchmark.js
|
||||||
@ -31,7 +31,7 @@ You may be limited to a maximal number of connections (open file descriptors). S
|
|||||||
ulimit -n 2048
|
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
|
```sh
|
||||||
$ node drain.js
|
$ node drain.js
|
||||||
|
Loading…
Reference in New Issue
Block a user