Home

Awesome

Windmark

crates.io docs.rs github.com

Windmark is an elegant and highly performant, async Gemini server framework for the modern age!

Now supporting both Tokio and async-std!

Usage

A macro-based "struct-router" is currently being developed for Windmark. A subset of Windmark's features are currently available for use through it. Check out Rossweisse for more information!

Features

FeatureDescription
defaultBase Windmark framework using Tokio
loggerEnables the default pretty_env_logger integration
auto-deduce-mimeExposes Responses and macros that automatically fill MIMEs for non-Gemini responses
response-macrosSimple macros for all Responses
tokioMarks Tokio as the asynchronous runtime
async-stdMarks async-std as the asynchronous runtime
preludeExposes the prelude module containing the most used Windmark features

Add Windmark and Tokio as Dependencies

# Cargo.toml

[dependencies]
windmark = "0.3.9"
tokio = { version = "1.26.0", features = ["full"] }

# If you would like to use the built-in logger (recommended)
# windmark = { version = "0.3.9", features = ["logger"] }

# If you would like to use the built-in MIME dedection when `Success`-ing a file
# (recommended)
# windmark = { version = "0.3.9", features = ["auto-deduce-mime"] }

# If you would like to use macro-based responses (as seen below)
# windmark = { version = "0.3.9", features = ["response-macros"] }

Implementing a Windmark Server

// src/main.rs

// ...

#[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("/", windmark::success!("Hello, World!"))
    .set_error_handler(|_|
      windmark::response::Response::permanent_failure("This route does not exist!")
    )
    .run()
    .await
}

Implementing a Windmark Server Using Rossweisse

// src/main.rs

// ...

#[rossweisse::router]
struct Router;

#[rossweisse::router]
impl Router {
  #[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

License

This project is licensed with the GNU General Public License v3.0.