aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-05-05 01:33:55 +0000
committerFuwn <[email protected]>2023-05-05 01:33:55 +0000
commitd66da17c17239408f2ddbc2794621e2d947056a3 (patch)
treee448da50c46c429f6ca672aa070577766fffc9bc /examples
parentdocs(rossweisse): revert to implementation (diff)
downloadwindmark-d66da17c17239408f2ddbc2794621e2d947056a3.tar.xz
windmark-d66da17c17239408f2ddbc2794621e2d947056a3.zip
feat(windmark): prelude feature flag
Diffstat (limited to 'examples')
-rw-r--r--examples/async.rs4
-rw-r--r--examples/async_stateful_module.rs4
-rw-r--r--examples/binary.rs2
-rw-r--r--examples/callbacks.rs4
-rw-r--r--examples/certificate.rs4
-rw-r--r--examples/default_logger.rs2
-rw-r--r--examples/empty.rs2
-rw-r--r--examples/error_handler.rs4
-rw-r--r--examples/fix_path.rs2
-rw-r--r--examples/input.rs4
-rw-r--r--examples/mime.rs4
-rw-r--r--examples/parameters.rs2
-rw-r--r--examples/partial.rs2
-rw-r--r--examples/query.rs2
-rw-r--r--examples/responses.rs2
-rw-r--r--examples/simple_async_std.rs6
-rw-r--r--examples/simple_tokio.rs6
-rw-r--r--examples/stateful_module.rs4
-rw-r--r--examples/stateless_module.rs6
-rw-r--r--examples/struct_router.rs7
20 files changed, 38 insertions, 35 deletions
diff --git a/examples/async.rs b/examples/async.rs
index d803ad6..f2674f0 100644
--- a/examples/async.rs
+++ b/examples/async.rs
@@ -19,7 +19,7 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- let mut router = windmark::Router::new();
+ let mut router = windmark::router::Router::new();
#[cfg(feature = "tokio")]
let async_clicks = std::sync::Arc::new(tokio::sync::Mutex::new(0));
#[cfg(feature = "async-std")]
@@ -35,7 +35,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
*clicks += 1;
- windmark::Response::success(*clicks)
+ windmark::response::Response::success(*clicks)
}
});
router.mount(
diff --git a/examples/async_stateful_module.rs b/examples/async_stateful_module.rs
index 3c35486..e19eb69 100644
--- a/examples/async_stateful_module.rs
+++ b/examples/async_stateful_module.rs
@@ -17,7 +17,7 @@
//! `cargo run --example async_stateful_module --features response-macros`
-use windmark::{context::HookContext, Router};
+use windmark::{context::HookContext, router::Router};
#[derive(Default)]
struct Clicker {
@@ -25,7 +25,7 @@ struct Clicker {
}
#[async_trait::async_trait]
-impl windmark::AsyncModule for Clicker {
+impl windmark::module::AsyncModule for Clicker {
async fn on_attach(&mut self, _router: &mut Router) {
println!("module 'clicker' has been attached!");
}
diff --git a/examples/binary.rs b/examples/binary.rs
index 2fbb652..3a86c17 100644
--- a/examples/binary.rs
+++ b/examples/binary.rs
@@ -22,7 +22,7 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- let mut router = windmark::Router::new();
+ let mut router = windmark::router::Router::new();
router.set_private_key_file("windmark_private.pem");
router.set_certificate_file("windmark_public.pem");
diff --git a/examples/callbacks.rs b/examples/callbacks.rs
index 58826e2..9d4acc1 100644
--- a/examples/callbacks.rs
+++ b/examples/callbacks.rs
@@ -21,7 +21,7 @@ use windmark::context::HookContext;
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.mount("/", windmark::success!("Hello!"))
@@ -33,7 +33,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)
})
.set_post_route_callback(
- |context: HookContext, content: &mut windmark::Response| {
+ |context: HookContext, content: &mut windmark::response::Response| {
content.content = content.content.replace("Hello", "Hi");
println!(
diff --git a/examples/certificate.rs b/examples/certificate.rs
index f93d724..6cd6def 100644
--- a/examples/certificate.rs
+++ b/examples/certificate.rs
@@ -17,11 +17,11 @@
//! `cargo run --example certificate --features response-macros`
-use windmark::Response;
+use windmark::response::Response;
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.mount("/secret", |context: windmark::context::RouteContext| {
diff --git a/examples/default_logger.rs b/examples/default_logger.rs
index 994bb6e..f7d5eb1 100644
--- a/examples/default_logger.rs
+++ b/examples/default_logger.rs
@@ -19,7 +19,7 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- let mut router = windmark::Router::new();
+ let mut router = windmark::router::Router::new();
router.set_private_key_file("windmark_private.pem");
router.set_certificate_file("windmark_public.pem");
diff --git a/examples/empty.rs b/examples/empty.rs
index 02e6254..893fd2b 100644
--- a/examples/empty.rs
+++ b/examples/empty.rs
@@ -19,7 +19,7 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.run()
diff --git a/examples/error_handler.rs b/examples/error_handler.rs
index 86ec337..93aa9c7 100644
--- a/examples/error_handler.rs
+++ b/examples/error_handler.rs
@@ -17,13 +17,13 @@
//! `cargo run --example error_handler`
-use windmark::Response;
+use windmark::response::Response;
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut error_count = 0;
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.set_error_handler(move |_| {
diff --git a/examples/fix_path.rs b/examples/fix_path.rs
index 1b64602..fe8fb2c 100644
--- a/examples/fix_path.rs
+++ b/examples/fix_path.rs
@@ -19,7 +19,7 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.set_fix_path(true)
diff --git a/examples/input.rs b/examples/input.rs
index 75e97cb..e8f3111 100644
--- a/examples/input.rs
+++ b/examples/input.rs
@@ -17,11 +17,11 @@
//! `cargo run --example input`
-use windmark::{context::RouteContext, Response};
+use windmark::{context::RouteContext, response::Response};
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.mount("/input", |context: RouteContext| {
diff --git a/examples/mime.rs b/examples/mime.rs
index 9f592f5..93ebabb 100644
--- a/examples/mime.rs
+++ b/examples/mime.rs
@@ -19,11 +19,11 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.mount("/mime", |_| {
- windmark::Response::success("Hello!".to_string())
+ windmark::response::Response::success("Hello!".to_string())
.with_mime("text/plain")
.clone()
})
diff --git a/examples/parameters.rs b/examples/parameters.rs
index e329e09..82a61a5 100644
--- a/examples/parameters.rs
+++ b/examples/parameters.rs
@@ -21,7 +21,7 @@ use windmark::success;
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.mount(
diff --git a/examples/partial.rs b/examples/partial.rs
index 70e05ab..d49256a 100644
--- a/examples/partial.rs
+++ b/examples/partial.rs
@@ -19,7 +19,7 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.add_header(|_| "This is fancy art.\n".to_string())
diff --git a/examples/query.rs b/examples/query.rs
index 38fc295..f144795 100644
--- a/examples/query.rs
+++ b/examples/query.rs
@@ -19,7 +19,7 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.mount(
diff --git a/examples/responses.rs b/examples/responses.rs
index c1bd533..3cb996a 100644
--- a/examples/responses.rs
+++ b/examples/responses.rs
@@ -21,7 +21,7 @@ use windmark::success;
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.mount(
diff --git a/examples/simple_async_std.rs b/examples/simple_async_std.rs
index 9896590..75cd66e 100644
--- a/examples/simple_async_std.rs
+++ b/examples/simple_async_std.rs
@@ -19,10 +19,12 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
- .mount("/", |_| windmark::Response::success("Hello, async-std!"))
+ .mount("/", |_| {
+ windmark::response::Response::success("Hello, async-std!")
+ })
.run()
.await
}
diff --git a/examples/simple_tokio.rs b/examples/simple_tokio.rs
index 1c9acec..ec64c49 100644
--- a/examples/simple_tokio.rs
+++ b/examples/simple_tokio.rs
@@ -19,10 +19,12 @@
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- windmark::Router::new()
+ windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
- .mount("/", |_| windmark::Response::success("Hello, Tokio!"))
+ .mount("/", |_| {
+ windmark::response::Response::success("Hello, Tokio!")
+ })
.run()
.await
}
diff --git a/examples/stateful_module.rs b/examples/stateful_module.rs
index 4347716..73b7663 100644
--- a/examples/stateful_module.rs
+++ b/examples/stateful_module.rs
@@ -17,14 +17,14 @@
//! `cargo run --example stateful_module --features response-macros`
-use windmark::{context::HookContext, Router};
+use windmark::{context::HookContext, router::Router};
#[derive(Default)]
struct Clicker {
clicks: usize,
}
-impl windmark::Module for Clicker {
+impl windmark::module::Module for Clicker {
fn on_attach(&mut self, _router: &mut Router) {
println!("module 'clicker' has been attached!");
}
diff --git a/examples/stateless_module.rs b/examples/stateless_module.rs
index f43ce16..f747aac 100644
--- a/examples/stateless_module.rs
+++ b/examples/stateless_module.rs
@@ -17,10 +17,10 @@
//! `cargo run --example stateless_module`
-use windmark::Router;
+use windmark::{response::Response, router::Router};
-fn smiley(_context: windmark::context::RouteContext) -> windmark::Response {
- windmark::Response::success("😀")
+fn smiley(_context: windmark::context::RouteContext) -> Response {
+ Response::success("😀")
}
fn emojis(router: &mut Router) { router.mount("/smiley", smiley); }
diff --git a/examples/struct_router.rs b/examples/struct_router.rs
index a636f7d..3401379 100644
--- a/examples/struct_router.rs
+++ b/examples/struct_router.rs
@@ -18,6 +18,7 @@
//! `cargo run --example struct_router`
use rossweisse::route;
+use windmark::response::Response;
#[rossweisse::router]
struct Router {
@@ -27,10 +28,8 @@ struct Router {
#[rossweisse::router]
impl Router {
#[route(index)]
- pub fn index(
- _context: windmark::context::RouteContext,
- ) -> windmark::Response {
- windmark::Response::success("Hello, World!")
+ pub fn index(_context: windmark::context::RouteContext) -> Response {
+ Response::success("Hello, World!")
}
}