-
-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- impl tower_service::Service for FilteredFuture
- add Filter::into_service function that converts a Warp Filter into a tower_service::Service - add example running a warp Filter on Hyper
- Loading branch information
Showing
8 changed files
with
110 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
extern crate warp; | ||
extern crate hyper; | ||
|
||
use warp::Filter; | ||
use hyper::Server; | ||
use hyper::service::{make_service_fn, service_fn}; | ||
use tower_service::Service; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let addr = ([0, 0, 0, 0], 3030).into(); | ||
|
||
let routes = warp::any().map(|| "hello world"); | ||
|
||
let make_service = make_service_fn(move |_| { | ||
let routes = routes.clone(); | ||
futures::future::ok::<_, hyper::Error>(service_fn(move |req| routes.into_service().call(req))) | ||
}); | ||
|
||
let server = Server::bind(&addr) | ||
.serve(make_service); | ||
|
||
if let Err(e) = server.await { | ||
eprintln!("server error: {}", e); | ||
} | ||
} |
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