aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-03-27 11:38:41 +0000
committerFuwn <[email protected]>2022-03-27 11:38:41 +0000
commitc60dd3ceda6b818271a48765f676bf3505dcbbeb (patch)
treed4a9a8caa94f259c2fef30e9cafea3d0533451de /examples
parentfeat(handler): fnmut partial (diff)
downloadwindmark-c60dd3ceda6b818271a48765f676bf3505dcbbeb.tar.xz
windmark-c60dd3ceda6b818271a48765f676bf3505dcbbeb.zip
feat(handler): more fnmut
Diffstat (limited to 'examples')
-rw-r--r--examples/windmark.rs52
1 files changed, 26 insertions, 26 deletions
diff --git a/examples/windmark.rs b/examples/windmark.rs
index 29376a8..7cbf60d 100644
--- a/examples/windmark.rs
+++ b/examples/windmark.rs
@@ -39,7 +39,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Response::PermanentFailure("e".into())
}))
.attach(|r| {
- r.mount("/module", |_| Response::Success("This is a module!".into()));
+ r.mount("/module", Box::new(|_| Response::Success("This is a module!".into())));
})
.set_pre_route_callback(Box::new(|stream, url, _| {
info!(
@@ -56,24 +56,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}))
.set_header(Box::new(|_| "```\nART IS COOL\n```".to_string()))
.set_footer(Box::new(|_| "Copyright 2022".to_string()))
- .mount("/", |_| {
+ .mount("/", Box::new(|_| {
Response::Success(
"# INDEX\n\nWelcome!\n\n=> /test Test Page\n=> /time Unix Epoch\n"
.to_string(),
)
- })
- .mount("/ip", |context| {
+ }))
+ .mount("/ip", Box::new(|context| {
Response::Success(
{ format!("Hello, {}", context.tcp.peer_addr().unwrap().ip()) }.into(),
)
- })
- .mount("/test", |_| {
+ }))
+ .mount("/test", Box::new(|_| {
Response::Success("hi there\n=> / back".to_string())
- })
- .mount("/temporary-failure", |_| {
+ }))
+ .mount("/temporary-failure", Box::new(|_| {
Response::TemporaryFailure("Woops, temporarily...".into())
- })
- .mount("/time", |_| {
+ }))
+ .mount("/time", Box::new(|_| {
Response::Success(
std::time::UNIX_EPOCH
.elapsed()
@@ -81,47 +81,47 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.as_nanos()
.to_string(),
)
- })
- .mount("/query", |context| {
+ }))
+ .mount("/query", Box::new(|context| {
Response::Success(format!(
"queries: {:?}",
windmark::utilities::queries_from_url(&context.url)
))
- })
- .mount("/param/:lang", |context| {
+ }))
+ .mount("/param/:lang", Box::new(|context| {
Response::Success(format!(
"Parameter lang is {}",
context.params.get("lang").unwrap()
))
- })
- .mount("/names/:first/:last", |context| {
+ }))
+ .mount("/names/:first/:last", Box::new(|context| {
Response::Success(format!(
"{} {}",
context.params.get("first").unwrap(),
context.params.get("last").unwrap()
))
- })
- .mount("/input", |context| {
+ }))
+ .mount("/input", Box::new(|context| {
if let Some(name) = context.url.query() {
Response::Success(format!("Your name is {}!", name))
} else {
Response::Input("What is your name?".into())
}
- })
- .mount("/sensitive-input", |context| {
+ }))
+ .mount("/sensitive-input", Box::new(|context| {
if let Some(password) = context.url.query() {
Response::Success(format!("Your password is {}!", password))
} else {
Response::SensitiveInput("What is your password?".into())
}
- })
- .mount("/error", |_| Response::CertificateNotValid("no".into()))
- .mount("/redirect", |_| {
+ }))
+ .mount("/error", Box::new(|_| Response::CertificateNotValid("no".into())))
+ .mount("/redirect", Box::new(|_| {
Response::PermanentRedirect("gemini://localhost/test".into())
- })
- .mount("/file", |_| {
+ }))
+ .mount("/file", Box::new(|_| {
Response::SuccessFile(include_bytes!("../LICENSE"))
- })
+ }))
.run()
.await
}