#server-framework #gemini #async-std

windmark

An elegant and highly performant async Gemini server framework

36 releases

0.3.11 Jul 17, 2024
0.3.9 May 5, 2023
0.2.5 Mar 31, 2023
0.1.20 Jul 31, 2022
0.1.7 Mar 31, 2022

#227 in Web programming

Download history 64/week @ 2024-06-25 3/week @ 2024-07-02 135/week @ 2024-07-16 8/week @ 2024-07-23 6/week @ 2024-07-30 90/week @ 2024-08-06 21/week @ 2024-08-13 3/week @ 2024-08-27 7/week @ 2024-09-03 10/week @ 2024-09-10 9/week @ 2024-09-17 85/week @ 2024-09-24 13/week @ 2024-10-01

117 downloads per month
Used in 3 crates

GPL-3.0-only

63KB
974 lines

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

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.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"] }

Implement 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
}

Implement 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.

An example of a fully featured Gemini capsule written using Windmark can be found here. This example Gemini capsule also happens to be the source code for Fuwn's (this library's author) personal Gemini capsule!

Modules

Modules are reusable extensions which can be procedurally mounted onto Windmark routers.

Add yours!

Capsules using Windmark

Add yours!

License

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

Dependencies

~5–18MB
~261K SLoC