Expand description
§Windmark
Windmark is an elegant and highly performant async Gemini server framework for the modern age!
Now supporting both Tokio and async-std!
§Usage
[!NOTE] A macro-based “
struct-router” is in active development as a simplified alternative to the standard server creation approach. Check out Rossweisse for more information!
§Features
| Feature | Description |
|---|---|
default | Base Windmark framework using Tokio |
logger | Enables the default pretty_env_logger integration |
auto-deduce-mime | Exposes Responses and macros that automatically fill MIMEs for non-Gemini responses |
response-macros | Simple macros for all Responses |
tokio | Marks Tokio as the asynchronous runtime |
async-std | Marks async-std as the asynchronous runtime |
prelude | Exposes the prelude module containing the most used Windmark features |
§Add Windmark and Tokio as Dependencies
# Cargo.toml
[dependencies]
windmark = "0.7.0"
tokio = { version = "1.26.0", features = ["full"] }
# If you would like to use the built-in logger (recommended)
# windmark = { version = "0.7.0", features = ["logger"] }
# If you would like to use the built-in MIME deduction when `Success`-ing a file
# (recommended)
# windmark = { version = "0.7.0", features = ["auto-deduce-mime"] }
# If you would like to use macro-based responses (as seen below)
# windmark = { version = "0.7.0", features = ["response-macros"] }§Implementing a Windmark Server
// src/main.rs
use windmark::response::Response;
#[windmark::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
windmark::router::Router::new()
.set_private_key_file("windmark_private.pem")
.set_certificate_file("windmark_public.pem")
.mount("/", |_| Response::success("Hello, World!"))
.set_error_handler(|_|
Response::permanent_failure("This route does not exist!")
)
.run()
.await
}§Implementing a Windmark Server Using Rossweisse
// src/main.rs
use windmark::response::Response;
#[rossweisse::router]
struct Router;
#[rossweisse::router]
impl Router {
#[rossweisse::route(index)]
pub fn index(
_context: windmark::context::RouteContext,
) -> Response {
Response::success("Hello, World!")
}
}
// ...§Examples
Examples can be found within the
examples/ directory
along with a rundown of each of their purposes and useful facts.
Run an example by cloning this repository and running cargo run --example example_name.
§Modules
Modules are composable extensions which can be procedurally mounted onto Windmark routers.
§Examples
- Simple Stateless Module
- Mounts the
/smileyroute, returning an 😀 emoji - Simple Stateful Module - Adds a click tracker (route hit tracker) that additionally notifies before and after route visits
- Windmark Comments - A fully featured comment engine for your capsule
§License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Modules§
- context
- handler
- module
- prelude
- response
- Content and response handlers
- router
- router_
option - utilities
- Utilities to make cumbersome tasks simpler
Macros§
- bad_
request - Trailing commas are not supported at the moment!
- bad_
request_ async - Trailing commas are not supported at the moment!
- binary_
success - Trailing commas are not supported at the moment!
- binary_
success_ auto - Trailing commas are not supported at the moment!
- binary_
success_ auto_ async - Trailing commas are not supported at the moment!
- certificate_
not_ authorised - Trailing commas are not supported at the moment!
- certificate_
not_ authorised_ async - Trailing commas are not supported at the moment!
- certificate_
not_ valid - Trailing commas are not supported at the moment!
- certificate_
not_ valid_ async - Trailing commas are not supported at the moment!
- cgi_
error - Trailing commas are not supported at the moment!
- cgi_
error_ async - Trailing commas are not supported at the moment!
- client_
certificate_ required - Trailing commas are not supported at the moment!
- client_
certificate_ required_ async - Trailing commas are not supported at the moment!
- gone
- Trailing commas are not supported at the moment!
- gone_
async - Trailing commas are not supported at the moment!
- input
- Trailing commas are not supported at the moment!
- input_
async - Trailing commas are not supported at the moment!
- not_
found - Trailing commas are not supported at the moment!
- not_
found_ async - Trailing commas are not supported at the moment!
- permanent_
failure - Trailing commas are not supported at the moment!
- permanent_
failure_ async - Trailing commas are not supported at the moment!
- permanent_
redirect - Trailing commas are not supported at the moment!
- permanent_
redirect_ async - Trailing commas are not supported at the moment!
- proxy_
error - Trailing commas are not supported at the moment!
- proxy_
error_ async - Trailing commas are not supported at the moment!
- proxy_
refused - Trailing commas are not supported at the moment!
- proxy_
refused_ async - Trailing commas are not supported at the moment!
- sensitive_
input - Trailing commas are not supported at the moment!
- sensitive_
input_ async - Trailing commas are not supported at the moment!
- server_
unavailable - Trailing commas are not supported at the moment!
- server_
unavailable_ async - Trailing commas are not supported at the moment!
- slow_
down - Trailing commas are not supported at the moment!
- slow_
down_ async - Trailing commas are not supported at the moment!
- success
- Trailing commas are not supported at the moment!
- success_
async - Trailing commas are not supported at the moment!
- temporary_
failure - Trailing commas are not supported at the moment!
- temporary_
failure_ async - Trailing commas are not supported at the moment!
- temporary_
redirect - Trailing commas are not supported at the moment!
- temporary_
redirect_ async - Trailing commas are not supported at the moment!