mirror of
https://github.com/actix/examples
synced 2024-11-23 14:31: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-web",
|
||||
"dotenv",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"log",
|
||||
"rusoto_core",
|
||||
"rusoto_s3",
|
||||
"sanitize-filename",
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user