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
opt-level = 3
# debug = true
[workspace]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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