diff options
| author | Fuwn <[email protected]> | 2022-03-27 07:00:44 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-27 07:00:44 +0000 |
| commit | 18d4ac1f2e9782654494c957927c2a5cc6a2915c (patch) | |
| tree | d5c13fa5595d2efe1cd9a724ddf13a116bc91d0c /src/lib.rs | |
| parent | docs(readme): fix example (diff) | |
| download | windmark-0.1.2.tar.xz windmark-0.1.2.zip | |
docs: extend0.1.2
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 55 |
1 files changed, 55 insertions, 0 deletions
@@ -16,6 +16,59 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only +//! # Windmark +//! +//! [](https://crates.io/crates/windmark) +//! [](https://docs.rs/windmark) +//! [](https://github.com/gemrest/windmark/actions/workflows/check.yaml) +//! +//! Windmark is an elegant and highly performant, async Gemini server framework. +//! +//! ## Usage +//! +//! ### Add Windmark as a dependency +//! +//! ```toml +//! # Cargo.toml +//! +//! [dependencies] +//! windmark = "0.1.2" +//! +//! # If you would like to use the built-in logger (recommended) +//! # windmark = { version = "0.1.2", features = ["logger"] } +//! ``` +//! +//! ### Implement a Windmark server +//! +//! ```rust +//! // src/main.rs +//! +//! use windmark::Response; +//! +//! #[windmark::main] +//! fn main() -> Result<(), Box<dyn std::error::Error>> { +//! windmark::Router::new() +//! .set_private_key_file("windmark_private.pem") +//! .set_certificate_chain_file("windmark_pair.pem") +//! .mount("/", |_| Response::Success("Hello, World!".into())) +//! .set_error_handler(|_| { +//! Response::PermanentFailure("This route does not exist!".into()) +//! }) +//! .run() +//! .await +//! } +//! ``` +//! +//! ## Examples +//! +//! Examples can be found within the +//! [`examples/`](https://github.com/gemrest/windmark/tree/main/examples) directory. +//! +//! ## License +//! +//! This project is licensed with the +//! [GNU General Public License v3.0](https://github.com/gemrest/windmark/blob/main/LICENSE). + #![feature(once_cell)] #![deny( warnings, @@ -53,6 +106,8 @@ use crate::{ returnable::{ErrorContext, RouteContext}, }; +/// A router which takes care of all tasks a Windmark server should handle: +/// response generation, panics, logging, and more. #[derive(Clone)] pub struct Router { routes: matchit::Router<RouteResponse>, |