🏗️ Elegant & Highly Performant Async Gemini Server Framework for the Modern Age
async framework gemini-protocol protocol gemini rust
at main 138 lines 4.5 kB view raw view rendered
1# Examples 2 3## [Async Stateful Module](./async_stateful_module.rs) 4 5`cargo run --example async_stateful_module --features response-macros` 6 7Demonstrates use of the `AsyncModule` trait by implementing the module 8`Clicker` which tracks the global number of visits to the capsule. 9 10This can easily be adapted to contain a hashmap of routes which are individually 11tracked for clicks. 12 13## [Async](./async.rs) 14 15`cargo run --example async --features response-macros` 16 17Demonstrates use of async routes through an async response macro and 18implementing a click tracker using a shared variable through an thread-safe, 19async mutex. 20 21## [Binary](./binary.rs) 22 23`cargo run --example binary --features response-macros` 24 25Demonstrates the binary response functionality by using both manual 26and automatic mime resolution (`--features auto-deduce-mime`). 27 28## [Callbacks](./callbacks.rs) 29 30`cargo run --example callbacks` 31 32Demonstrates use of the pre and post-route callback handlers. 33 34## [Certificate](./certificate.rs) 35 36`cargo run --example certificate --features response-macros` 37 38Demonstrate the various certificate related responses as well as 39reading the client certificate to give conditional access. 40 41## [Default Logger](./default_logger.rs) 42 43`cargo run --example default_logger --features logger,response-macros` 44 45A simple example showing the use of the default default logger implementation. 46 47## [Empty](./empty.rs) 48 49`cargo run --example empty` 50 51An empty example which starts up a server but has no mounted routes. 52 53## [Error Handler](./error_handler.rs) 54 55`cargo run --example error_handler` 56 57Creates an intentional error within a route, invoking the error handler. 58 59## [Fix Path](./fix_path.rs) 60 61`cargo run --example fix_path --features response-macros` 62 63A simple example which demonstrates use of the path fixer that attempts to resolve the closest match of a route when an invalid route is visited. 64 65This feature is limited to simple resolution patches such as resolving 66trailing and missing trailing slashes. If your capsule requires a more sophisticated path fixer, please use any of the provided mechanisms to do so before your routes execute. 67 68## [Input](./input.rs) 69 70`cargo run --example input` 71 72Demonstrates how to accept and inspect both standard and sensitive input. 73 74## [MIME](./mime.rs) 75 76`cargo run --example mime` 77 78Demonstrate how to modify the MIME of a response before use. 79 80## [Parameters](./parameters.rs) 81 82`cargo run --example parameters --features response-macros` 83 84Demonstrate the use of route parameters (not URL queries). 85 86## [Partial](./partial.rs) 87 88`cargo run --example partial` 89 90Demonstrates use of appending headers and footers to routes, globally. 91 92If you would like to conditionally append headers and footers based on route, please look into using a templating framework. 93 94## [Query](./query.rs) 95 96`cargo run --example input --features response-macros` 97 98Demonstrates the inspection of URL queries parameters. 99 100## [Responses](./responses.rs) 101 102`cargo run --example responses --features response-macros` 103 104Demonstrates the use of a wide variety of responses, additionally exposing the flexibility of response bodies types. 105 106## [Simple `async-std`](./simple_async_std.rs) 107 108`cargo run --example simple_async_std --features async-std` 109 110Demonstrates how to explicitly specify Windmark to use the [`async-std`](https://github.com/async-rs/async-std) runtime. 111 112If the `async-std` feature is NOT enabled, Windmark will default to using Tokio as the async runtime. 113 114## [Simple Tokio](./simple_tokio.rs) 115 116`cargo run --example simple_async_std --features async-std` 117 118Demonstrates how to explicitly specify Windmark to use the [Tokio](https://github.com/tokio-rs/tokio) runtime. 119 120## [Stateful Module](./stateful_module.rs) 121 122`cargo run --example stateful_module --features response-macros` 123 124Demonstrates use of `Module`s by implementing a click tracker 125 126Identical in functionality to the Async Stateful Module example, just not asynchronous. 127 128## [Stateless Module](./stateless_module.rs) 129 130`cargo run --example stateless_module` 131 132Demonstrates use of a stateless module. 133 134Unlike a `Module`, a stateless module is not encapsulated into a `struct`, but is a simple function which is used to perform operations. 135 136Stateless modules are able to emulate stateful modules employing `static` variables. The earliest Windmark modules (add-ons) were made this way. 137 138The only requirement of a module is to implement the signature of a stateless module: `FnMut(&mut Router) -> ()`.