Skip to main content

Crate windmark

Crate windmark 

Source
Expand description

§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

[!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

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

§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!

Attribute Macros§

main
Marks async function to be executed by the selected runtime. This macro helps set up a Runtime without requiring the user to use Runtime or Builder directly.