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