1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-01-18 05:41:50 +01:00

use workspace

This commit is contained in:
Nikolay Kim 2017-12-31 21:55:25 -08:00
parent 8e89ff1d1e
commit d2f54b7d19
18 changed files with 53 additions and 20 deletions

View File

@ -99,3 +99,5 @@ version_check = "0.1"
lto = true lto = true
opt-level = 3 opt-level = 3
# debug = true # debug = true
[workspace]

View File

@ -2,6 +2,7 @@
name = "basic" name = "basic"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[dependencies] [dependencies]
futures = "*" futures = "*"

View File

@ -9,9 +9,10 @@ use futures::Stream;
use actix::*; use actix::*;
use actix_web::*; use actix_web::*;
#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe};
use actix_web::middleware::RequestSession; use actix_web::middleware::RequestSession;
use futures::future::{FutureResult, result}; use futures::future::{FutureResult, result};
#[cfg(unix)]
use actix::actors::signal::{ProcessSignals, Subscribe};
/// simple handler /// simple handler
fn index(mut req: HttpRequest) -> Result<HttpResponse> { fn index(mut req: HttpRequest) -> Result<HttpResponse> {
@ -96,7 +97,9 @@ fn main() {
.bind("0.0.0.0:8080").unwrap() .bind("0.0.0.0:8080").unwrap()
.start(); .start();
if cfg!(target_os = "linux") { // Subscribe to unix signals // Subscribe to unix signals
#[cfg(unix)]
{
let signals = Arbiter::system_registry().get::<ProcessSignals>(); let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(addr.subscriber())); signals.send(Subscribe(addr.subscriber()));
} }

View File

@ -2,6 +2,7 @@
name = "diesel-example" name = "diesel-example"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[dependencies] [dependencies]
env_logger = "0.4" env_logger = "0.4"

View File

@ -2,6 +2,7 @@
name = "json-example" name = "json-example"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[dependencies] [dependencies]
bytes = "0.4" bytes = "0.4"

View File

@ -9,7 +9,8 @@ extern crate serde_json;
use actix::*; use actix::*;
use actix_web::*; use actix_web::*;
#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; #[cfg(unix)]
use actix::actors::signal::{ProcessSignals, Subscribe};
use bytes::BytesMut; use bytes::BytesMut;
use futures::{Future, Stream}; use futures::{Future, Stream};
@ -96,7 +97,9 @@ fn main() {
.shutdown_timeout(1) .shutdown_timeout(1)
.start(); .start();
if cfg!(target_os = "linux") { // Subscribe to unix signals // Subscribe to unix signals
#[cfg(unix)]
{
let signals = Arbiter::system_registry().get::<ProcessSignals>(); let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(addr.subscriber())); signals.send(Subscribe(addr.subscriber()));
} }

View File

@ -2,6 +2,7 @@
name = "multipart-example" name = "multipart-example"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[[bin]] [[bin]]
name = "multipart" name = "multipart"

View File

@ -6,7 +6,8 @@ extern crate futures;
use actix::*; use actix::*;
use actix_web::*; use actix_web::*;
#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; #[cfg(unix)]
use actix::actors::signal::{ProcessSignals, Subscribe};
use futures::{Future, Stream}; use futures::{Future, Stream};
use futures::future::{result, Either}; use futures::future::{result, Either};
@ -55,7 +56,9 @@ fn main() {
.bind("127.0.0.1:8080").unwrap() .bind("127.0.0.1:8080").unwrap()
.start(); .start();
if cfg!(target_os = "linux") { // Subscribe to unix signals // Subscribe to unix signals
#[cfg(unix)]
{
let signals = Arbiter::system_registry().get::<ProcessSignals>(); let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(addr.subscriber())); signals.send(Subscribe(addr.subscriber()));
} }

View File

@ -2,6 +2,7 @@
name = "signals" name = "signals"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[[bin]] [[bin]]
name = "server" name = "server"

View File

@ -5,7 +5,8 @@ extern crate env_logger;
use actix::*; use actix::*;
use actix_web::*; use actix_web::*;
#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; #[cfg(unix)]
use actix::actors::signal::{ProcessSignals, Subscribe};
struct MyWebSocket; struct MyWebSocket;
@ -34,7 +35,9 @@ fn main() {
.bind("127.0.0.1:8080").unwrap() .bind("127.0.0.1:8080").unwrap()
.start(); .start();
if cfg!(target_os = "linux") { // Subscribe to unix signals // Subscribe to unix signals
#[cfg(unix)]
{
let signals = Arbiter::system_registry().get::<ProcessSignals>(); let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(addr.subscriber())); signals.send(Subscribe(addr.subscriber()));
} }

View File

@ -2,6 +2,7 @@
name = "state" name = "state"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[dependencies] [dependencies]
futures = "*" futures = "*"

View File

@ -7,11 +7,14 @@ extern crate actix;
extern crate actix_web; extern crate actix_web;
extern crate env_logger; extern crate env_logger;
use actix::*;
use actix_web::*;
#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe};
use std::cell::Cell; use std::cell::Cell;
use actix::*;
use actix_web::*;
#[cfg(unix)]
use actix::actors::signal::{ProcessSignals, Subscribe};
/// Application state
struct AppState { struct AppState {
counter: Cell<usize>, counter: Cell<usize>,
} }
@ -55,7 +58,6 @@ impl Handler<ws::Message> for MyWebSocket {
} }
} }
fn main() { fn main() {
::std::env::set_var("RUST_LOG", "actix_web=info"); ::std::env::set_var("RUST_LOG", "actix_web=info");
let _ = env_logger::init(); let _ = env_logger::init();
@ -74,7 +76,9 @@ fn main() {
.bind("127.0.0.1:8080").unwrap() .bind("127.0.0.1:8080").unwrap()
.start(); .start();
if cfg!(target_os = "linux") { // Subscribe to unix signals // Subscribe to unix signals
#[cfg(unix)]
{
let signals = Arbiter::system_registry().get::<ProcessSignals>(); let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(addr.subscriber())); signals.send(Subscribe(addr.subscriber()));
} }

View File

@ -2,6 +2,7 @@
name = "template-tera" name = "template-tera"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[dependencies] [dependencies]
env_logger = "0.4" env_logger = "0.4"

View File

@ -6,7 +6,9 @@ extern crate tera;
use actix::*; use actix::*;
use actix_web::*; use actix_web::*;
#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; #[cfg(unix)]
use actix::actors::signal::{ProcessSignals, Subscribe};
struct State { struct State {
template: tera::Tera, // <- store tera template in application state template: tera::Tera, // <- store tera template in application state
@ -43,7 +45,8 @@ fn main() {
.bind("127.0.0.1:8080").unwrap() .bind("127.0.0.1:8080").unwrap()
.start(); .start();
if cfg!(target_os = "linux") { // Subscribe to unix signals #[cfg(unix)]
{ // Subscribe to unix signals
let signals = Arbiter::system_registry().get::<ProcessSignals>(); let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(addr.subscriber())); signals.send(Subscribe(addr.subscriber()));
} }

View File

@ -2,6 +2,7 @@
name = "tls-example" name = "tls-example"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[[bin]] [[bin]]
name = "server" name = "server"

View File

@ -8,7 +8,7 @@ use std::io::Read;
use actix::*; use actix::*;
use actix_web::*; use actix_web::*;
#[cfg(target_os = "linux")] #[cfg(unix)]
use actix::actors::signal::{ProcessSignals, Subscribe}; use actix::actors::signal::{ProcessSignals, Subscribe};
/// somple handle /// somple handle
@ -49,7 +49,7 @@ fn main() {
.start_ssl(&pkcs12).unwrap(); .start_ssl(&pkcs12).unwrap();
// Subscribe to unix signals // Subscribe to unix signals
#[cfg(target_os = "linux")] #[cfg(unix)]
{ {
let signals = Arbiter::system_registry().get::<ProcessSignals>(); let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(addr.subscriber())); signals.send(Subscribe(addr.subscriber()));

View File

@ -2,6 +2,7 @@
name = "websocket-example" name = "websocket-example"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../.."
[[bin]] [[bin]]
name = "server" name = "server"

View File

@ -17,7 +17,8 @@ use std::time::Instant;
use actix::*; use actix::*;
use actix_web::*; use actix_web::*;
#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe}; #[cfg(unix)]
use actix::actors::signal::{ProcessSignals, Subscribe};
mod codec; mod codec;
mod server; mod server;
@ -30,7 +31,7 @@ struct WsChatSessionState {
} }
/// Entry point for our route /// Entry point for our route
fn chat_route(req: HttpRequest<WsChatSessionState>) -> Result<Reply> { fn chat_route(req: HttpRequest<WsChatSessionState>) -> Result<HttpResponse> {
ws::start( ws::start(
req, req,
WsChatSession { WsChatSession {
@ -215,7 +216,9 @@ fn main() {
.bind("127.0.0.1:8080").unwrap() .bind("127.0.0.1:8080").unwrap()
.start(); .start();
if cfg!(target_os = "linux") { // Subscribe to unix signals // Subscribe to unix signals
#[cfg(unix)]
{
let signals = Arbiter::system_registry().get::<ProcessSignals>(); let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(addr.subscriber())); signals.send(Subscribe(addr.subscriber()));
} }