mirror of
https://github.com/actix/actix-web.git
synced 2024-12-20 23:26:44 +00:00
update examples
This commit is contained in:
parent
80285f2a32
commit
eb041de36d
5 changed files with 9 additions and 8 deletions
|
@ -57,6 +57,7 @@ script:
|
|||
cd examples/hello-world && cargo check && cd ../..
|
||||
cd examples/multipart && cargo check && cd ../..
|
||||
cd examples/json && cargo check && cd ../..
|
||||
cd examples/state && cargo check && cd ../..
|
||||
cd examples/template_tera && cargo check && cd ../..
|
||||
cd examples/diesel && cargo check && cd ../..
|
||||
cd examples/tls && cargo check && cd ../..
|
||||
|
|
|
@ -31,14 +31,14 @@ use db::{CreateUser, DbExecutor};
|
|||
|
||||
/// State with DbExecutor address
|
||||
struct State {
|
||||
db: Addr<Syn<DbExecutor>>,
|
||||
db: Addr<Syn, DbExecutor>,
|
||||
}
|
||||
|
||||
/// Async request handler
|
||||
fn index(req: HttpRequest<State>) -> Box<Future<Item=HttpResponse, Error=Error>> {
|
||||
let name = &req.match_info()["name"];
|
||||
|
||||
req.state().db.call_fut(CreateUser{name: name.to_owned()})
|
||||
req.state().db.call(CreateUser{name: name.to_owned()})
|
||||
.from_err()
|
||||
.and_then(|res| {
|
||||
match res {
|
||||
|
|
|
@ -44,7 +44,7 @@ impl Handler<ws::Message> for MyWebSocket {
|
|||
println!("WS({}): {:?}", self.counter, msg);
|
||||
match msg {
|
||||
ws::Message::Ping(msg) => ctx.pong(&msg),
|
||||
ws::Message::Text(text) => ctx.text(&text),
|
||||
ws::Message::Text(text) => ctx.text(text),
|
||||
ws::Message::Binary(bin) => ctx.binary(bin),
|
||||
ws::Message::Closed | ws::Message::Error => {
|
||||
ctx.stop();
|
||||
|
|
|
@ -28,7 +28,7 @@ fn main() {
|
|||
()
|
||||
})
|
||||
.map(|(reader, writer)| {
|
||||
let addr: Addr<Syn<_>> = ChatClient::create(|ctx| {
|
||||
let addr: Addr<Syn, _> = ChatClient::create(|ctx| {
|
||||
ChatClient::add_stream(reader, ctx);
|
||||
ChatClient(writer)
|
||||
});
|
||||
|
|
|
@ -333,7 +333,7 @@ impl<H: IntoHttpHandler> HttpServer<H>
|
|||
impl<H: IntoHttpHandler> HttpServer<H>
|
||||
{
|
||||
/// Start listening for incoming tls connections.
|
||||
pub fn start_tls(mut self, acceptor: TlsAcceptor) -> io::Result<SyncAddress<Self>> {
|
||||
pub fn start_tls(mut self, acceptor: TlsAcceptor) -> io::Result<Addr<Syn, Self>> {
|
||||
if self.sockets.is_empty() {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound"))
|
||||
} else {
|
||||
|
@ -350,7 +350,7 @@ impl<H: IntoHttpHandler> HttpServer<H>
|
|||
|
||||
// start http server actor
|
||||
let signals = self.subscribe_to_signals();
|
||||
let addr: SyncAddress<_> = Actor::start(self);
|
||||
let addr: Addr<Syn, _> = Actor::start(self);
|
||||
signals.map(|signals| signals.send(
|
||||
signal::Subscribe(addr.clone().subscriber())));
|
||||
Ok(addr)
|
||||
|
@ -364,7 +364,7 @@ impl<H: IntoHttpHandler> HttpServer<H>
|
|||
/// Start listening for incoming tls connections.
|
||||
///
|
||||
/// This method sets alpn protocols to "h2" and "http/1.1"
|
||||
pub fn start_ssl(mut self, mut builder: SslAcceptorBuilder) -> io::Result<SyncAddress<Self>>
|
||||
pub fn start_ssl(mut self, mut builder: SslAcceptorBuilder) -> io::Result<Addr<Syn, Self>>
|
||||
{
|
||||
if self.sockets.is_empty() {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound"))
|
||||
|
@ -394,7 +394,7 @@ impl<H: IntoHttpHandler> HttpServer<H>
|
|||
|
||||
// start http server actor
|
||||
let signals = self.subscribe_to_signals();
|
||||
let addr: SyncAddress<_> = Actor::start(self);
|
||||
let addr: Addr<Syn, _> = Actor::start(self);
|
||||
signals.map(|signals| signals.send(
|
||||
signal::Subscribe(addr.clone().subscriber())));
|
||||
Ok(addr)
|
||||
|
|
Loading…
Reference in a new issue