-
-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into allow-empty-path!
- Loading branch information
Showing
18 changed files
with
177 additions
and
25 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "warp" | ||
version = "0.2.4" # don't forget to update html_root_url | ||
version = "0.2.5" # don't forget to update html_root_url | ||
description = "serve the web at warp speeds" | ||
authors = ["Sean McArthur <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -30,16 +30,16 @@ multipart = { version = "0.17", default-features = false, features = ["server"], | |
scoped-tls = "1.0" | ||
serde = "1.0" | ||
serde_json = "1.0" | ||
serde_urlencoded = "0.6" | ||
serde_urlencoded = "0.7" | ||
tokio = { version = "0.2", features = ["fs", "stream", "sync", "time"] } | ||
tracing = { version = "0.1", default-features = false, features = ["log", "std"] } | ||
tracing-futures = { version = "0.2", default-features = false, features = ["std-future"] } | ||
tower-service = "0.3" | ||
# tls is enabled by default, we don't want that yet | ||
tokio-tungstenite = { version = "0.10", default-features = false, optional = true } | ||
urlencoding = "1.0.0" | ||
tokio-tungstenite = { version = "0.11", default-features = false, optional = true } | ||
percent-encoding = "2.1" | ||
pin-project = "0.4.17" | ||
tokio-rustls = { version = "0.13.1", optional = true } | ||
tokio-rustls = { version = "0.14", optional = true } | ||
|
||
[dev-dependencies] | ||
pretty_env_logger = "0.4" | ||
|
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,31 @@ | ||
#![deny(warnings)] | ||
use warp::Filter; | ||
|
||
fn hello_wrapper<F, T>( | ||
filter: F, | ||
) -> impl Filter<Extract = (&'static str,)> + Clone + Send + Sync + 'static | ||
where | ||
F: Filter<Extract = (T,), Error = std::convert::Infallible> + Clone + Send + Sync + 'static, | ||
F::Extract: warp::Reply, | ||
{ | ||
warp::any() | ||
.map(|| { | ||
println!("before filter"); | ||
}) | ||
.untuple_one() | ||
.and(filter) | ||
.map(|_arg| "wrapped hello world") | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// Match any request and return hello world! | ||
let routes = warp::any() | ||
.map(|| "hello world") | ||
.boxed() | ||
.recover(|_err| async { Ok("recovered") }) | ||
// wrap the filter with hello_wrapper | ||
.with(warp::wrap_fn(hello_wrapper)); | ||
|
||
warp::serve(routes).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
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
Oops, something went wrong.