mirror of
https://github.com/actix/examples
synced 2024-11-23 14:31:07 +01:00
v3 examples (#364)
This commit is contained in:
parent
3f2b2708c3
commit
49e29a5751
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,12 +1,10 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/*/target/
|
||||
target/
|
||||
**/target
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
|
||||
/*/Cargo.lock
|
||||
Cargo.lock
|
||||
**/Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
@ -3,13 +3,10 @@ name = "async_data_factory"
|
||||
version = "0.1.0"
|
||||
authors = ["fakeshadow <24548779@qq.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.1.1"
|
||||
actix-web = { version = "2.0.0" }
|
||||
num_cpus = "1.13.0"
|
||||
actix-web = "3"
|
||||
num_cpus = "1.13"
|
||||
redis = { version = "0.16.0", default-features = false, features = ["tokio-rt-core"] }
|
||||
# redis_tang is an redis pool for test purpose
|
||||
redis_tang = "0.1.0"
|
||||
redis_tang = "0.1"
|
||||
|
@ -3,7 +3,7 @@ use actix_web::{get, App, HttpServer};
|
||||
|
||||
use redis_tang::{Builder, Pool, RedisManager};
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let redis_url =
|
||||
std::env::var("REDIS_URL").unwrap_or_else(|_| String::from("redis://127.0.0.1"));
|
||||
@ -14,6 +14,7 @@ async fn main() -> std::io::Result<()> {
|
||||
let pool = pool_builder(num_cpus, redis_url.as_str())
|
||||
.await
|
||||
.expect("fail to build pool");
|
||||
|
||||
let pool = RedisWrapper(pool);
|
||||
|
||||
HttpServer::new(move || {
|
||||
|
@ -3,16 +3,13 @@ name = "async_db"
|
||||
version = "2.0.0"
|
||||
authors = ["Darin Gordon <dkcdkg@gmail.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
|
||||
actix-web = "3"
|
||||
env_logger = "0.7"
|
||||
failure = "0.1.7"
|
||||
futures = "0.3.1"
|
||||
num_cpus = "1.10.0"
|
||||
num_cpus = "1.13"
|
||||
r2d2 = "0.8.2"
|
||||
r2d2_sqlite = "0.14"
|
||||
rusqlite = "0.21"
|
||||
|
@ -48,7 +48,7 @@ async fn parallel_weather(db: web::Data<Pool>) -> Result<HttpResponse, AWError>
|
||||
Ok(HttpResponse::Ok().json(result.map_err(AWError::from)?))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -3,12 +3,9 @@ name = "awc_examples"
|
||||
version = "2.0.0"
|
||||
authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = { version="2.0.0", features=["openssl"] }
|
||||
|
||||
actix-web = { version = "3", features = ["openssl"] }
|
||||
env_logger = "0.7"
|
||||
futures = "0.3.1"
|
||||
serde = { version = "1.0.43", features = ["derive"] }
|
||||
|
@ -80,7 +80,7 @@ async fn create_something(
|
||||
.body(serde_json::to_string(&d).unwrap()))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -5,8 +5,7 @@ authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = { version="2.0.0", features = ["openssl"] }
|
||||
actix-web = { version = "3", features = ["openssl"] }
|
||||
actix-service = "1.0.0"
|
||||
bytes = "0.5.3"
|
||||
env_logger = "0.7"
|
||||
@ -14,3 +13,6 @@ futures = "0.3.1"
|
||||
serde = { version = "^1.0", features = ["derive"] }
|
||||
serde_json = "1.0.39"
|
||||
time = "0.1.42"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1"
|
||||
|
@ -2,7 +2,7 @@ use actix_web::{middleware, App, HttpServer};
|
||||
|
||||
use async_ex2::appconfig::config_app;
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -3,11 +3,9 @@ name = "async_pg"
|
||||
version = "0.1.0"
|
||||
authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-web = "3"
|
||||
config = "0.10.1"
|
||||
deadpool-postgres = "0.5.0"
|
||||
derive_more = "0.99.2"
|
||||
|
@ -111,7 +111,7 @@ use dotenv::dotenv;
|
||||
use handlers::add_user;
|
||||
use tokio_postgres::NoTls;
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
dotenv().ok();
|
||||
|
||||
|
@ -3,10 +3,7 @@ name = "awc_https"
|
||||
version = "0.1.0"
|
||||
authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = { version = "2.0.0", features = ["openssl"] }
|
||||
actix-web = { version = "3", features = ["openssl"] }
|
||||
openssl = "0.10.28"
|
||||
|
@ -7,7 +7,7 @@ use openssl::ssl::{SslConnector, SslMethod};
|
||||
async fn index(_req: HttpRequest) -> HttpResponse {
|
||||
let builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
|
||||
let client = Client::build()
|
||||
let client = Client::builder()
|
||||
.connector(Connector::new().ssl(builder.build()).finish())
|
||||
.finish();
|
||||
|
||||
@ -31,7 +31,7 @@ async fn index(_req: HttpRequest) -> HttpResponse {
|
||||
HttpResponse::Ok().content_type("image/jpeg").body(payload)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let port = 3000;
|
||||
|
||||
|
@ -2,16 +2,11 @@
|
||||
name = "basics"
|
||||
version = "2.0.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-files = "0.2.1"
|
||||
actix-session = "0.3.0"
|
||||
actix-utils = "1.0.3"
|
||||
|
||||
futures = "0.3.1"
|
||||
actix-web = "3"
|
||||
actix-files = "0.3"
|
||||
actix-session = "0.4"
|
||||
actix-utils = "2"
|
||||
env_logger = "0.7"
|
||||
bytes = "0.5"
|
||||
|
@ -1,17 +1,12 @@
|
||||
#[macro_use]
|
||||
extern crate actix_web;
|
||||
|
||||
use std::{env, io};
|
||||
|
||||
use actix_files as fs;
|
||||
use actix_session::{CookieSession, Session};
|
||||
use actix_utils::mpsc;
|
||||
use actix_web::http::{header, Method, StatusCode};
|
||||
use actix_web::{
|
||||
error, guard, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer,
|
||||
Result,
|
||||
error, get, guard, middleware, web, App, Error, HttpRequest, HttpResponse,
|
||||
HttpServer, Result,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use std::{env, io};
|
||||
|
||||
/// favicon handler
|
||||
#[get("/favicon")]
|
||||
@ -50,21 +45,24 @@ async fn response_body(path: web::Path<String>) -> HttpResponse {
|
||||
let text = format!("Hello {}!", *path);
|
||||
|
||||
let (tx, rx_body) = mpsc::channel();
|
||||
let _ = tx.send(Ok::<_, Error>(Bytes::from(text)));
|
||||
let _ = tx.send(Ok::<_, Error>(web::Bytes::from(text)));
|
||||
|
||||
HttpResponse::Ok().streaming(rx_body)
|
||||
}
|
||||
|
||||
/// handler with path parameters like `/user/{name}/`
|
||||
async fn with_param(req: HttpRequest, path: web::Path<(String,)>) -> HttpResponse {
|
||||
async fn with_param(
|
||||
req: HttpRequest,
|
||||
web::Path((name,)): web::Path<(String,)>,
|
||||
) -> HttpResponse {
|
||||
println!("{:?}", req);
|
||||
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/plain")
|
||||
.body(format!("Hello {}!", path.0))
|
||||
.body(format!("Hello {}!", name))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
env::set_var("RUST_LOG", "actix_web=debug,actix_server=info");
|
||||
env_logger::init();
|
||||
|
@ -3,10 +3,8 @@ name = "actix-casbin-example"
|
||||
version = "0.1.0"
|
||||
authors = ["Chojan Shang <psiace@outlook.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0"
|
||||
actix-rt = "1.1.0"
|
||||
actix-web = "3"
|
||||
casbin = "0.6.0"
|
||||
loge = {version = "0.4", default-features = false, features = ["colored", "chrono"]}
|
||||
|
@ -24,7 +24,7 @@ async fn fail(enforcer: web::Data<RwLock<Enforcer>>, req: HttpRequest) -> HttpRe
|
||||
HttpResponse::Ok().body("Fail: alice is not data1_admin.") // In fact, it can't be displayed.
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "info");
|
||||
std::env::set_var("LOGE_FORMAT", "target");
|
||||
|
@ -3,11 +3,9 @@ name = "cookie-auth"
|
||||
version = "2.0.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-identity = "0.2.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
actix-identity = "0.3"
|
||||
env_logger = "0.7"
|
||||
rand = "0.7.3"
|
||||
rand = "0.7"
|
||||
|
@ -20,7 +20,7 @@ async fn logout(id: Identity) -> HttpResponse {
|
||||
HttpResponse::Found().header("location", "/").finish()
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -2,14 +2,9 @@
|
||||
name = "cookie-session"
|
||||
version = "1.0.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-session = "0.3.0"
|
||||
actix-rt = "1.0.0"
|
||||
|
||||
futures = "0.3.1"
|
||||
time = "0.1"
|
||||
actix-web = "3"
|
||||
actix-session = "0.4"
|
||||
env_logger = "0.7"
|
||||
|
@ -25,7 +25,7 @@ async fn index(session: Session, req: HttpRequest) -> Result<&'static str> {
|
||||
Ok("welcome!")
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -5,14 +5,10 @@ authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"Rob Ede <robjtede@icloud.com>",
|
||||
]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
|
||||
bytes = "0.5"
|
||||
actix-web = "3"
|
||||
diesel = { version = "^1.1.0", features = ["sqlite", "r2d2"] }
|
||||
dotenv = "0.15"
|
||||
env_logger = "0.7"
|
||||
|
@ -62,7 +62,7 @@ async fn add_user(
|
||||
Ok(HttpResponse::Ok().json(user))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -4,8 +4,5 @@ version = "0.1.0"
|
||||
authors = ["docker_sample <docker_sample@sample.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-web = "3"
|
||||
|
@ -15,7 +15,7 @@ async fn again() -> impl Responder {
|
||||
HttpResponse::Ok().body("Hello world again!")
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
println!("Starting actix-web server");
|
||||
|
||||
|
2
error_handling/.gitignore
vendored
2
error_handling/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
/target
|
||||
**/*.rs.bk
|
@ -3,12 +3,9 @@ name = "error_handling"
|
||||
version = "1.0.0"
|
||||
authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
derive_more = "0.99.2"
|
||||
futures = "0.3.1"
|
||||
rand = "0.7"
|
||||
env_logger = "0.7"
|
||||
|
@ -87,7 +87,7 @@ async fn do_something() -> Result<HttpResponse, Error> {
|
||||
Ok(HttpResponse::Ok().body("Nothing interesting happened. Try again."))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -3,9 +3,10 @@ name = "form-example"
|
||||
version = "1.0.0"
|
||||
authors = ["Gorm Casper <gcasper@gmail.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
actix-web = "3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1"
|
||||
|
@ -8,7 +8,7 @@ struct AppState {
|
||||
foo: String,
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
|
@ -5,6 +5,8 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
env_logger = "0.7"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1"
|
||||
|
@ -5,7 +5,7 @@ async fn index(req: HttpRequest) -> &'static str {
|
||||
"Hello world!"
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -5,9 +5,6 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>", "Rotem Yaari <vmalloc@gmail.com>"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = { version = "2.0.0", features=["openssl"] }
|
||||
actix-web = { version = "3", features = ["openssl"] }
|
||||
clap = "2.32.0"
|
||||
futures = "0.3.1"
|
||||
failure = "0.1.3"
|
||||
url = "2.0"
|
||||
|
@ -40,7 +40,7 @@ async fn forward(
|
||||
Ok(client_resp.body(res.body().await?))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let matches = clap::App::new("HTTP Proxy")
|
||||
.arg(
|
||||
|
@ -2,18 +2,16 @@
|
||||
name = "json-example"
|
||||
version = "0.1.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
actix-service = "1.0.0"
|
||||
|
||||
bytes = "0.5.2"
|
||||
futures = "0.3.1"
|
||||
env_logger = "0.7"
|
||||
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
json = "0.12"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1"
|
||||
|
@ -1,7 +1,6 @@
|
||||
use actix_web::{
|
||||
error, middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer,
|
||||
};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::StreamExt;
|
||||
use json::JsonValue;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -31,7 +30,7 @@ const MAX_SIZE: usize = 262_144; // max payload size is 256k
|
||||
/// This handler manually load request payload and parse json object
|
||||
async fn index_manual(mut payload: web::Payload) -> Result<HttpResponse, Error> {
|
||||
// payload is a stream of Bytes objects
|
||||
let mut body = BytesMut::new();
|
||||
let mut body = web::BytesMut::new();
|
||||
while let Some(chunk) = payload.next().await {
|
||||
let chunk = chunk?;
|
||||
// limit max size of in-memory payload
|
||||
@ -47,7 +46,7 @@ async fn index_manual(mut payload: web::Payload) -> Result<HttpResponse, Error>
|
||||
}
|
||||
|
||||
/// This handler manually load request payload and parse json-rust
|
||||
async fn index_mjsonrust(body: Bytes) -> Result<HttpResponse, Error> {
|
||||
async fn index_mjsonrust(body: web::Bytes) -> Result<HttpResponse, Error> {
|
||||
// body is loaded, now we can deserialize json-rust
|
||||
let result = json::parse(std::str::from_utf8(&body).unwrap()); // return Result
|
||||
let injson: JsonValue = match result {
|
||||
@ -59,7 +58,7 @@ async fn index_mjsonrust(body: Bytes) -> Result<HttpResponse, Error> {
|
||||
.body(injson.dump()))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -4,9 +4,6 @@ version = "0.1.0"
|
||||
authors = ["Stig Johan Berggren <stigjb@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
serde = "1.0.104"
|
||||
actix-web = "3"
|
||||
serde = "1"
|
||||
|
@ -29,7 +29,7 @@ fn json_error_handler(err: error::JsonPayloadError, _req: &HttpRequest) -> error
|
||||
error::InternalError::from_response(err, resp).into()
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
|
@ -5,9 +5,7 @@ authors = ["Kai Yao <kai.b.yao@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
failure = "0.1"
|
||||
futures = "0.3"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
@ -35,7 +35,7 @@ async fn index() -> Result<web::HttpResponse, Error> {
|
||||
})
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
let ip_address = "127.0.0.1:8000";
|
||||
println!("Running server on {}", ip_address);
|
||||
|
@ -3,11 +3,9 @@ name = "jsonrpc-example"
|
||||
version = "2.0.0"
|
||||
authors = ["mohanson <mohanson@outlook.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
bytes = "0.5"
|
||||
env_logger = "0.7"
|
||||
futures = "0.3.1"
|
||||
|
@ -6,7 +6,6 @@ use std::pin::Pin;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::time::Duration;
|
||||
|
||||
use actix_rt::time::delay_for;
|
||||
use actix_web::{middleware, web, App, Error, HttpResponse, HttpServer};
|
||||
use bytes::Bytes;
|
||||
use futures::{Future, FutureExt};
|
||||
@ -115,7 +114,7 @@ impl ImplNetwork for ObjNetwork {
|
||||
d: u64,
|
||||
) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn error::Error>>>>> {
|
||||
async move {
|
||||
delay_for(Duration::from_secs(d)).await;
|
||||
actix_web::rt::time::delay_for(Duration::from_secs(d)).await;
|
||||
Ok(String::from("pong"))
|
||||
}
|
||||
.boxed_local()
|
||||
@ -141,7 +140,7 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "info");
|
||||
env_logger::init();
|
||||
|
@ -7,9 +7,7 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
futures = "0.3.1"
|
||||
actix-web = "3"
|
||||
|
||||
juniper = "0.14"
|
||||
|
||||
|
@ -13,7 +13,7 @@ mod db;
|
||||
mod handlers;
|
||||
mod schemas;
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
dotenv::dotenv().ok();
|
||||
std::env::set_var("RUST_LOG", "actix_web=info,info");
|
||||
|
@ -5,8 +5,7 @@ authors = ["pyros2097 <pyros2097@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
env_logger = "0.7.1"
|
||||
serde = "1.0.103"
|
||||
serde_json = "1.0.44"
|
||||
|
@ -33,7 +33,7 @@ async fn graphql(
|
||||
.body(user))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -5,10 +5,9 @@ authors = ["Gorm Casper <gcasper@gmail.com>", "Sven-Hendrik Haase <svenstaro@gma
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-service = "1.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
bytes = "0.5"
|
||||
actix-service = "1"
|
||||
actix-web = "3"
|
||||
|
||||
env_logger = "0.7"
|
||||
futures = "0.3.1"
|
||||
pin-project = "0.4.6"
|
||||
pin-project = "0.4"
|
||||
|
@ -1,6 +1,6 @@
|
||||
# middleware examples
|
||||
|
||||
This example showcases a bunch of different uses of middlewares. See also the [Middleware guide](https://actix.rs/docs/middleware/)..
|
||||
This example showcases a bunch of different uses of middlewares. See also the [Middleware guide](https://actix.rs/docs/middleware/).
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -13,7 +13,7 @@ mod redirect;
|
||||
#[allow(dead_code)]
|
||||
mod simple;
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=debug");
|
||||
env_logger::init();
|
||||
|
@ -4,8 +4,8 @@ use std::rc::Rc;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_web::web::BytesMut;
|
||||
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error, HttpMessage};
|
||||
use bytes::BytesMut;
|
||||
use futures::future::{ok, Future, Ready};
|
||||
use futures::stream::StreamExt;
|
||||
|
||||
|
@ -5,8 +5,8 @@ use std::task::{Context, Poll};
|
||||
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_web::body::{BodySize, MessageBody, ResponseBody};
|
||||
use actix_web::web::{Bytes, BytesMut};
|
||||
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::future::{ok, Ready};
|
||||
|
||||
pub struct Logging;
|
||||
@ -86,13 +86,16 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[pin_project::pin_project(PinnedDrop)]
|
||||
pub struct BodyLogger<B> {
|
||||
#[pin]
|
||||
body: ResponseBody<B>,
|
||||
body_accum: BytesMut,
|
||||
}
|
||||
|
||||
impl<B> Drop for BodyLogger<B> {
|
||||
fn drop(&mut self) {
|
||||
#[pin_project::pinned_drop]
|
||||
impl<B> PinnedDrop for BodyLogger<B> {
|
||||
fn drop(self: Pin<&mut Self>) {
|
||||
println!("response body: {:?}", self.body_accum);
|
||||
}
|
||||
}
|
||||
@ -102,10 +105,15 @@ impl<B: MessageBody> MessageBody for BodyLogger<B> {
|
||||
self.body.size()
|
||||
}
|
||||
|
||||
fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
|
||||
match self.body.poll_next(cx) {
|
||||
fn poll_next(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Option<Result<Bytes, Error>>> {
|
||||
let this = self.project();
|
||||
|
||||
match this.body.poll_next(cx) {
|
||||
Poll::Ready(Some(Ok(chunk))) => {
|
||||
self.body_accum.extend_from_slice(&chunk);
|
||||
this.body_accum.extend_from_slice(&chunk);
|
||||
Poll::Ready(Some(Ok(chunk)))
|
||||
}
|
||||
Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(e))),
|
||||
|
@ -10,9 +10,8 @@ repository = "https://github.com/actix/examples"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3"
|
||||
actix-multipart = "0.3"
|
||||
futures = "0.3.1"
|
||||
actix-multipart = "0.2.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
async-std = "1.4.0"
|
||||
sanitize-filename = "0.2"
|
||||
|
@ -38,7 +38,7 @@ fn index() -> HttpResponse {
|
||||
HttpResponse::Ok().body(html)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
|
||||
async_std::fs::create_dir_all("./tmp").await?;
|
||||
|
@ -7,10 +7,9 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3"
|
||||
actix-multipart = "0.3"
|
||||
futures = "0.3.1"
|
||||
actix-multipart = "0.2.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
rusoto_s3 = "0.43.0"
|
||||
rusoto_core = "0.43.0"
|
||||
bytes = { version = "0.5", features = ["serde"] }
|
||||
|
@ -72,7 +72,7 @@ fn index() -> HttpResponse {
|
||||
HttpResponse::Ok().body(html)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
dotenv().ok();
|
||||
let aws_access_key_id =
|
||||
|
@ -10,8 +10,7 @@ repository = "https://github.com/actix/examples"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
actix-multipart = "0.2.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-multipart = "0.3"
|
||||
actix-web = "3"
|
||||
futures = "0.3.1"
|
||||
sanitize-filename = "0.2"
|
||||
|
@ -10,10 +10,12 @@ async fn save_file(mut payload: Multipart) -> Result<HttpResponse, Error> {
|
||||
let content_type = field.content_disposition().unwrap();
|
||||
let filename = content_type.get_filename().unwrap();
|
||||
let filepath = format!("./tmp/{}", sanitize_filename::sanitize(&filename));
|
||||
|
||||
// File::create is blocking operation, use threadpool
|
||||
let mut f = web::block(|| std::fs::File::create(filepath))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Field in turn is stream of *Bytes* object
|
||||
while let Some(chunk) = field.next().await {
|
||||
let data = chunk.unwrap();
|
||||
@ -38,7 +40,7 @@ fn index() -> HttpResponse {
|
||||
HttpResponse::Ok().body(html)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
|
||||
std::fs::create_dir_all("./tmp").unwrap();
|
||||
|
@ -3,10 +3,8 @@ name = "openssl-example"
|
||||
version = "0.2.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = { version = "2.0.0", features = ["openssl"] }
|
||||
actix-web = { version = "3", features = ["openssl"] }
|
||||
env_logger = "0.7"
|
||||
openssl = "0.10"
|
||||
|
@ -11,7 +11,7 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||
.body("Welcome!"))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=debug");
|
||||
env_logger::init();
|
||||
|
@ -2,7 +2,6 @@
|
||||
name = "protobuf-example"
|
||||
version = "0.2.0"
|
||||
authors = ["kingxsp <jin.hb.zh@outlook.com>, Yuki Okushi <huyuumi.dev@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
@ -11,7 +10,6 @@ env_logger = "0.7.1"
|
||||
prost = "0.6.1"
|
||||
prost-derive = "0.6.1"
|
||||
|
||||
actix = "0.9.0"
|
||||
actix-protobuf = "0.5.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix = "0.10"
|
||||
actix-protobuf = "0.6"
|
||||
actix-web = "3"
|
||||
|
@ -8,6 +8,7 @@ use actix_web::*;
|
||||
pub struct MyObj {
|
||||
#[prost(int32, tag = "1")]
|
||||
pub number: i32,
|
||||
|
||||
#[prost(string, tag = "2")]
|
||||
pub name: String,
|
||||
}
|
||||
@ -17,7 +18,7 @@ async fn index(msg: ProtoBuf<MyObj>) -> Result<HttpResponse> {
|
||||
HttpResponse::Ok().protobuf(msg.0) // <- send response
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=debug,actix_server=info");
|
||||
env_logger::init();
|
||||
|
@ -5,10 +5,8 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-web = "3"
|
||||
|
||||
futures = "0.3.1"
|
||||
env_logger = "0.7"
|
||||
uuid = { version = "0.8", features = ["v4"] }
|
||||
|
||||
|
@ -31,7 +31,7 @@ async fn index(
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=debug");
|
||||
env_logger::init();
|
||||
|
@ -5,14 +5,16 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>", "dowwie <dkcdkg@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-session = "0.3.0"
|
||||
actix-redis = { version = "0.8.0", features = ["web"] }
|
||||
actix-web = "3"
|
||||
actix-session = "0.4"
|
||||
actix-redis = "0.9"
|
||||
env_logger = "0.7"
|
||||
serde = { version = "^1.0", features = ["derive"] }
|
||||
actix-service = "1.0.0"
|
||||
actix-http = "1.0.0"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
actix-service = "1"
|
||||
actix-http = "2"
|
||||
rand = "0.7.3"
|
||||
serde_json = "1.0.40"
|
||||
time = "0.1.42"
|
||||
time = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1"
|
||||
|
@ -72,7 +72,7 @@ async fn logout(session: Session) -> Result<HttpResponse> {
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info,actix_redis=info");
|
||||
env_logger::init();
|
||||
@ -308,7 +308,9 @@ mod test {
|
||||
.into_iter()
|
||||
.find(|c| c.name() == "test-session")
|
||||
.unwrap();
|
||||
assert!(&time::now().tm_year != &cookie_4.expires().map(|t| t.tm_year).unwrap());
|
||||
|
||||
let now = time::OffsetDateTime::now_utc();
|
||||
assert!(now.year() != cookie_4.expires().map(|t| t.year()).unwrap());
|
||||
|
||||
// Step 10: GET index, including session cookie #2 in request
|
||||
// - set-cookie actix-session will be in response (session cookie #3)
|
||||
|
@ -5,11 +5,10 @@ authors = ["dowwie <dkcdkg@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix = "0.9.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-redis = "0.8.0"
|
||||
futures = "0.3.1"
|
||||
redis-async = "0.6.1"
|
||||
serde = { version = "1.0.71", features = ["derive"] }
|
||||
actix = "0.10"
|
||||
actix-web = "3"
|
||||
actix-redis = "0.9"
|
||||
futures = "0.3"
|
||||
redis-async = "0.6.3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
env_logger = "0.7"
|
||||
|
@ -1,12 +1,9 @@
|
||||
#[macro_use]
|
||||
extern crate redis_async;
|
||||
use serde::Deserialize;
|
||||
|
||||
use actix::prelude::*;
|
||||
use actix_redis::{Command, RedisActor};
|
||||
use actix_web::{middleware, web, App, Error as AWError, HttpResponse, HttpServer};
|
||||
use futures::future::join_all;
|
||||
use redis_async::resp::RespValue;
|
||||
use redis_async::{resp::RespValue, resp_array};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct CacheInfo {
|
||||
@ -74,7 +71,7 @@ async fn del_stuff(redis: web::Data<Addr<RedisActor>>) -> Result<HttpResponse, A
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=trace,actix_redis=trace");
|
||||
env_logger::init();
|
||||
|
@ -6,6 +6,5 @@ edition = "2018"
|
||||
description = "Run actix-web in separate thread"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
env_logger = "0.7"
|
||||
|
@ -1,8 +1,7 @@
|
||||
use std::sync::mpsc;
|
||||
use std::{thread, time};
|
||||
|
||||
use actix_rt::System;
|
||||
use actix_web::{dev::Server, middleware, web, App, HttpRequest, HttpServer};
|
||||
use actix_web::{dev::Server, middleware, rt, web, App, HttpRequest, HttpServer};
|
||||
|
||||
async fn index(req: HttpRequest) -> &'static str {
|
||||
println!("REQ: {:?}", req);
|
||||
@ -10,7 +9,7 @@ async fn index(req: HttpRequest) -> &'static str {
|
||||
}
|
||||
|
||||
fn run_app(tx: mpsc::Sender<Server>) -> std::io::Result<()> {
|
||||
let mut sys = System::new("test");
|
||||
let mut sys = rt::System::new("test");
|
||||
|
||||
// srv is server controller type, `dev::Server`
|
||||
let srv = HttpServer::new(|| {
|
||||
@ -48,5 +47,5 @@ fn main() {
|
||||
|
||||
println!("STOPPING SERVER");
|
||||
// init stop server and wait until server gracefully exit
|
||||
System::new("").block_on(srv.stop(true));
|
||||
rt::System::new("").block_on(srv.stop(true));
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
name = "rustls-example"
|
||||
version = "1.0.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[[bin]]
|
||||
@ -11,7 +10,6 @@ path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.7"
|
||||
rustls = "0.16"
|
||||
actix-web = { version = "2.0.0", features = ["rustls"] }
|
||||
actix-files = "0.2.1"
|
||||
actix-rt = "1.0.0"
|
||||
rustls = "0.18"
|
||||
actix-web = { version = "3", features = ["rustls"] }
|
||||
actix-files = "0.3"
|
||||
|
@ -14,7 +14,7 @@ async fn index(req: HttpRequest) -> HttpResponse {
|
||||
.body("Welcome!")
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
if std::env::var("RUST_LOG").is_err() {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
|
@ -2,12 +2,10 @@
|
||||
name = "server-sent-events"
|
||||
version = "1.0.0"
|
||||
authors = ["Arve Seljebu"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-web = "3"
|
||||
env_logger = "0.7"
|
||||
futures = "0.3.1"
|
||||
tokio = "0.2"
|
||||
tokio = { version = "0.2", features = ["sync"] }
|
||||
|
@ -1,6 +1,6 @@
|
||||
const http = require('http')
|
||||
|
||||
const n = 1000;
|
||||
const n = 100;
|
||||
let connected = 0;
|
||||
let messages = 0;
|
||||
let start = Date.now();
|
||||
|
@ -3,13 +3,13 @@ use std::sync::Mutex;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::Duration;
|
||||
|
||||
use actix_web::rt::time::{interval_at, Instant};
|
||||
use actix_web::web::{Bytes, Data, Path};
|
||||
use actix_web::{web, App, Error, HttpResponse, HttpServer, Responder};
|
||||
use futures::{Stream, StreamExt};
|
||||
use tokio::sync::mpsc::{channel, Receiver, Sender};
|
||||
use tokio::time::{interval_at, Instant};
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
env_logger::init();
|
||||
let data = Broadcaster::create();
|
||||
@ -39,7 +39,6 @@ async fn new_client(broadcaster: Data<Mutex<Broadcaster>>) -> impl Responder {
|
||||
|
||||
HttpResponse::Ok()
|
||||
.header("content-type", "text/event-stream")
|
||||
.no_chunking()
|
||||
.streaming(rx)
|
||||
}
|
||||
|
||||
@ -74,7 +73,7 @@ impl Broadcaster {
|
||||
}
|
||||
|
||||
fn spawn_ping(me: Data<Mutex<Self>>) {
|
||||
actix_rt::spawn(async move {
|
||||
actix_web::rt::spawn(async move {
|
||||
let mut task = interval_at(Instant::now(), Duration::from_secs(10));
|
||||
while let Some(_) = task.next().await {
|
||||
me.lock().unwrap().remove_stale_clients();
|
||||
|
@ -6,8 +6,7 @@ edition = "2018"
|
||||
description = "Send a request to the server to shut it down"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-web = "3"
|
||||
env_logger = "0.7"
|
||||
futures = "0.3"
|
||||
tokio = { version = "0.2.11", features = ["signal"] }
|
||||
tokio = { version = "0.2", features = ["signal"] }
|
||||
|
@ -15,7 +15,7 @@ async fn stop(stopper: web::Data<mpsc::Sender<()>>) -> HttpResponse {
|
||||
HttpResponse::NoContent().finish()
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_server=debug,actix_web=debug");
|
||||
env_logger::init();
|
||||
|
@ -6,20 +6,21 @@ edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-identity = "0.2.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
actix-identity = "0.3"
|
||||
|
||||
# FIXME: Specify the commit hash to use bindgen v0.50.
|
||||
argonautica = { git = "https://github.com/bcmyers/argonautica", rev = "67fc8d8d7d67696cd8ca7a59b92531f06b089212" }
|
||||
chrono = { version = "0.4.6", features = ["serde"] }
|
||||
derive_more = "0.99.0"
|
||||
diesel = { version = "1.4.2", features = ["postgres", "uuidv07", "r2d2", "chrono"] }
|
||||
diesel = { version = "1.4.5", features = ["postgres", "uuidv07", "r2d2", "chrono"] }
|
||||
dotenv = "0.15"
|
||||
env_logger = "0.7"
|
||||
futures = "0.3.1"
|
||||
r2d2 = "0.8"
|
||||
lazy_static = "1.3.0"
|
||||
lazy_static = "1.4.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
sparkpost = "0.5.2"
|
||||
uuid = { version = "0.8", features = ["serde", "v4"] }
|
||||
time = "0.2"
|
||||
|
@ -5,6 +5,7 @@ use actix_identity::{CookieIdentityPolicy, IdentityService};
|
||||
use actix_web::{middleware, web, App, HttpServer};
|
||||
use diesel::prelude::*;
|
||||
use diesel::r2d2::{self, ConnectionManager};
|
||||
use time::Duration;
|
||||
|
||||
mod auth_handler;
|
||||
mod email_service;
|
||||
@ -15,7 +16,7 @@ mod register_handler;
|
||||
mod schema;
|
||||
mod utils;
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
dotenv::dotenv().ok();
|
||||
std::env::set_var(
|
||||
@ -44,7 +45,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.name("auth")
|
||||
.path("/")
|
||||
.domain(domain.as_str())
|
||||
.max_age_time(chrono::Duration::days(1))
|
||||
.max_age_time(Duration::days(1))
|
||||
.secure(false), // this can only be true if you have https
|
||||
))
|
||||
.data(web::JsonConfig::default().limit(4096))
|
||||
|
@ -7,13 +7,11 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3"
|
||||
listenfd = "0.3.3"
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.1.0"
|
||||
serde = "1.0.106"
|
||||
serde_json = "1.0.51"
|
||||
sqlx = { version = "0.3", features = [ "postgres" ] }
|
||||
futures = "0.3.4"
|
||||
dotenv = "0.15.0"
|
||||
env_logger = "0.7.1"
|
||||
log = "0.4.8"
|
||||
|
@ -25,7 +25,7 @@ async fn index() -> impl Responder {
|
||||
)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> Result<()> {
|
||||
dotenv().ok();
|
||||
env_logger::init();
|
||||
|
@ -5,7 +5,5 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
futures = "0.3.1"
|
||||
actix-web = "3"
|
||||
env_logger = "0.7"
|
||||
|
@ -48,7 +48,7 @@ async fn index(
|
||||
HttpResponse::Ok().body(body)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -2,13 +2,9 @@
|
||||
name = "static_index"
|
||||
version = "2.0.0"
|
||||
authors = ["Jose Marinez <digeratus@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3.1"
|
||||
actix-web = "3"
|
||||
actix-files = "0.3"
|
||||
env_logger = "0.7"
|
||||
|
||||
actix-web = "2.0.0"
|
||||
actix-files = "0.2.1"
|
||||
actix-rt = "1.0.0"
|
||||
|
@ -1,7 +1,7 @@
|
||||
use actix_files::Files;
|
||||
use actix_web::{middleware, App, HttpServer};
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -5,8 +5,7 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
askama = "0.9"
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -28,7 +28,7 @@ async fn index(query: web::Query<HashMap<String, String>>) -> Result<HttpRespons
|
||||
Ok(HttpResponse::Ok().content_type("text/html").body(s))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
// start http server
|
||||
HttpServer::new(move || {
|
||||
|
@ -5,8 +5,7 @@ authors = ["Alexandru Tiniuc <tiniuc.alexandru@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-http = "1.0.1"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-http = "2"
|
||||
actix-web = "3"
|
||||
handlebars = { version = "3.0.0", features = ["dir_source"] }
|
||||
serde_json = "1.0"
|
||||
|
@ -39,7 +39,7 @@ async fn user(
|
||||
HttpResponse::Ok().body(body)
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
// Handlebars uses a repository for the compiled templates. This object must be
|
||||
// shared between the application threads, and is therefore passed to the
|
||||
|
@ -2,12 +2,10 @@
|
||||
name = "template-tera"
|
||||
version = "2.0.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.7"
|
||||
tera = "1.0"
|
||||
actix-http = "1.0.1"
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-http = "2"
|
||||
actix-web = "3"
|
||||
|
@ -26,7 +26,7 @@ async fn index(
|
||||
Ok(HttpResponse::Ok().content_type("text/html").body(s))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -5,17 +5,15 @@ authors = ["Juan Aguilar Santillana <mhpoin@gmail.com>"]
|
||||
publish = false
|
||||
edition = "2018"
|
||||
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3"
|
||||
env_logger = "0.7"
|
||||
|
||||
yarte = { version = "0.8", features = ["html-min"] }
|
||||
|
||||
actix-rt = "1.0"
|
||||
actix-web = "2.0.0"
|
||||
|
||||
[build-dependencies.yarte_helpers]
|
||||
version = "0.8"
|
||||
default-features = false
|
||||
features = ["config"]
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1"
|
||||
|
@ -26,7 +26,7 @@ async fn index(
|
||||
.map_err(|_| ErrorInternalServerError("Some error message"))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
@ -5,10 +5,10 @@ version = "2.0.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "2.0.0"
|
||||
actix-files = "0.2.1"
|
||||
actix-session = "0.3.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
actix-files = "0.3"
|
||||
actix-session = "0.4"
|
||||
|
||||
dotenv = "0.15"
|
||||
env_logger = "0.7"
|
||||
futures = "0.3.1"
|
||||
|
@ -20,7 +20,7 @@ mod session;
|
||||
|
||||
static SESSION_SIGNING_KEY: &[u8] = &[0; 32];
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
dotenv().ok();
|
||||
|
||||
|
@ -5,7 +5,7 @@ authors = ["Anton Patrushev <apatrushev@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix = "0.9"
|
||||
actix = "0.10"
|
||||
actix-rt = "1.1"
|
||||
tokio = "0.2"
|
||||
tokio-util = { version = "0.3", features = [ "codec", "udp" ] }
|
||||
|
@ -2,10 +2,8 @@
|
||||
name = "unix-socket"
|
||||
version = "1.0.0"
|
||||
authors = ["Messense Lv <messense@icloud.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.7"
|
||||
actix-web = "2.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "3"
|
||||
|
@ -4,7 +4,7 @@ async fn index(_req: HttpRequest) -> &'static str {
|
||||
"Hello world!"
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
#[cfg(unix)]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
::std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
|
||||
|
4
web-cors/backend/.gitignore
vendored
4
web-cors/backend/.gitignore
vendored
@ -1,4 +0,0 @@
|
||||
|
||||
/target/
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
@ -5,9 +5,9 @@ authors = ["krircc <krircc@aliyun.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0"
|
||||
actix-cors = "0.2.0"
|
||||
actix-web = "3"
|
||||
actix-cors = "0.3"
|
||||
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
env_logger = "0.7"
|
||||
|
@ -3,7 +3,7 @@ use actix_web::{http::header, middleware::Logger, web, App, HttpServer};
|
||||
|
||||
mod user;
|
||||
|
||||
#[actix_rt::main]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user