-
-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
1,711 additions
and
1,643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
#![deny(warnings)] | ||
extern crate pretty_env_logger; | ||
extern crate warp; | ||
|
||
fn main() { | ||
#[warp::tokio_rt] | ||
async fn main() { | ||
pretty_env_logger::init(); | ||
|
||
warp::serve(warp::fs::dir("examples/dir")).run(([127, 0, 0, 1], 3030)); | ||
warp::serve(warp::fs::dir("examples/dir")).run(([127, 0, 0, 1], 3030)).await; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
extern crate pretty_env_logger; | ||
extern crate tokio; | ||
extern crate warp; | ||
// extern crate pretty_env_logger; | ||
|
||
use std::time::Duration; | ||
use tokio::{clock::now, timer::Interval}; | ||
use warp::{Filter, Stream}; | ||
// use std::time::Duration; | ||
// use tokio::{clock::now, timer::Interval}; | ||
// use futures::StreamExt; | ||
// use warp::Filter; | ||
|
||
fn main() { | ||
pretty_env_logger::init(); | ||
// #[warp::tokio_rt] | ||
// async fn main() { | ||
// pretty_env_logger::init(); | ||
|
||
// let routes = warp::path("ticks") | ||
// .and(warp::sse()) | ||
// .map(|sse: warp::sse::Sse| { | ||
// let mut counter: u64 = 0; | ||
// // create server event source | ||
// let event_stream = Interval::new(now(), Duration::from_secs(1)).map(move |_| { | ||
// counter += 1; | ||
// // create server-sent event | ||
// Ok(warp::sse::data(counter)) | ||
// }); | ||
// // reply using server-sent events | ||
// sse.reply(event_stream) | ||
// }); | ||
|
||
let routes = warp::path("ticks") | ||
.and(warp::sse()) | ||
.map(|sse: warp::sse::Sse| { | ||
let mut counter: u64 = 0; | ||
// create server event source | ||
let event_stream = Interval::new(now(), Duration::from_secs(1)).map(move |_| { | ||
counter += 1; | ||
// create server-sent event | ||
warp::sse::data(counter) | ||
}); | ||
// reply using server-sent events | ||
sse.reply(event_stream) | ||
}); | ||
// warp::serve(routes).run(([127, 0, 0, 1], 3030)).await; | ||
// } | ||
|
||
fn main() { | ||
|
||
warp::serve(routes).run(([127, 0, 0, 1], 3030)); | ||
} |
Oops, something went wrong.