8
8
A modular HTTP server library in Rust.
9
9
10
10
# Features
11
-
12
11
- ` forbid(unsafe_code) `
13
12
- Threaded request handlers:<br >
14
13
` FnOnce(Request) -> Response + 'static + Clone + Send + Sync `
@@ -23,27 +22,24 @@ A modular HTTP server library in Rust.
23
22
- Good test coverage (63%)
24
23
25
24
# Limitations
26
-
27
25
- New, not proven in production.
28
26
- To do:
29
- - Request timeouts
30
- - ` chunked ` transfer-encoding for request bodies
31
- - gzip
32
- - brotli
33
- - TLS
34
- - automatically getting TLS certs via ACME
35
- - Drop idle connections when approaching connection limit.
36
- - Denial-of-Service mitigation: source throttling, minimum throughput
37
- - Complete functional test suite
38
- - Missing load tests
39
- - Disk space usage limits
27
+ - Request timeouts
28
+ - ` chunked ` transfer-encoding for request bodies
29
+ - gzip
30
+ - brotli
31
+ - TLS
32
+ - automatically getting TLS certs via ACME
33
+ - Drop idle connections when approaching connection limit.
34
+ - Denial-of-Service mitigation: source throttling, minimum throughput
35
+ - Complete functional test suite
36
+ - Missing load tests
37
+ - Disk space usage limits
40
38
41
39
# Examples
42
-
43
40
Complete examples: [ ` examples/ ` ] ( https://github.com/mleonhard/servlin/tree/main/examples ) .
44
41
45
42
Simple example:
46
-
47
43
``` rust
48
44
use serde :: Deserialize ;
49
45
use serde_json :: json;
@@ -93,11 +89,8 @@ executor.block_on(
93
89
. spawn_and_join (request_handler )
94
90
). unwrap ();
95
91
```
96
-
97
92
# Cargo Geiger Safety Report
98
-
99
93
```
100
-
101
94
Metric output format: x/y
102
95
x = unsafe code used by the build
103
96
y = total unsafe code found in the crate
@@ -236,68 +229,64 @@ Functions Expressions Impls Traits Methods Dependency
236
229
101/547 7066/13995 105/153 3/6 187/326
237
230
238
231
```
239
-
240
232
# Alternatives
241
-
242
233
See [ rust-webserver-comparison.md] ( https://github.com/mleonhard/servlin/blob/main/rust-webserver-comparison.md ) .
243
234
244
235
# Changelog
245
-
246
236
- v0.7.0 2025-01-03
247
- - ` log_request_and_response ` to log ` duration_ms ` tag.
248
- - Fix typo in function name ` Response::internal_server_errror_500 ` .
249
- - Close connection on 5xx error.
250
- - Acceptor thread to log errors, not panic.
251
- - Add [ ` Request::parse_url ` ] .
252
- - Add [ ` Response::too_many_requests_429 ` ] .
253
- - Implement ` Into<TagList> ` for arrays.
237
+ - ` log_request_and_response ` to log ` duration_ms ` tag.
238
+ - Fix typo in function name ` Response::internal_server_errror_500 ` .
239
+ - Close connection on 5xx error.
240
+ - Acceptor thread to log errors, not panic.
241
+ - Add [ ` Request::parse_url ` ] .
242
+ - Add [ ` Response::too_many_requests_429 ` ] .
243
+ - Implement ` Into<TagList> ` for arrays.
254
244
- v0.6.0 2024-11-02
255
- - Remove ` servlin::reexports ` module.
256
- - Use ` safina ` v0.6.0.
245
+ - Remove ` servlin::reexports ` module.
246
+ - Use ` safina ` v0.6.0.
257
247
- v0.5.1 2024-10-26 - Remove dependency on ` once_cell ` .
258
248
- v0.5.0 2024-10-21 - Remove ` LogFileWriterBuilder ` .
259
249
- v0.4.3 - Implement ` From<Cow<'_, str>> ` and ` From<&Path> ` for ` TagValue ` .
260
250
- v0.4.2 - Implement ` Seek ` for ` BodyReader ` .
261
251
- v0.4.1
262
- - Add ` Request::opt_json ` .
263
- - Implement ` From<LoggerStoppedError> ` for ` Error ` .
252
+ - Add ` Request::opt_json ` .
253
+ - Implement ` From<LoggerStoppedError> ` for ` Error ` .
264
254
- v0.4.0
265
- - Changed ` Response::json ` to return ` Result<Response, Error> ` .
266
- - Changed ` log_request_and_response ` to return ` Result ` .
267
- - Added ` Response::unprocessable_entity_422 ` .
255
+ - Changed ` Response::json ` to return ` Result<Response, Error> ` .
256
+ - Changed ` log_request_and_response ` to return ` Result ` .
257
+ - Added ` Response::unprocessable_entity_422 ` .
268
258
- v0.3.2 - Fix bug in ` Response::include_dir ` redirects.
269
259
- v0.3.1
270
- - Add ` Response::redirect_301 `
271
- - ` Response::include_dir ` to redirect from ` /somedir ` to ` /somedir/ ` so relative URLs will work.
260
+ - Add ` Response::redirect_301 `
261
+ - ` Response::include_dir ` to redirect from ` /somedir ` to ` /somedir/ ` so relative URLs will work.
272
262
- v0.3.0 - Changed ` Response::include_dir ` to take ` &Request ` and look for ` index.html ` in dirs.
273
263
- v0.2.0
274
- - Added:
275
- - ` log_request_and_response ` and other logging tooling
276
- - ` Response::ok_200() `
277
- - ` Response::unauthorized_401() `
278
- - ` Response::forbidden_403() `
279
- - ` Response::internal_server_errror_500() `
280
- - ` Response::not_implemented_501() `
281
- - ` Response::service_unavailable_503() `
282
- - ` EventSender::is_connected() `
283
- - ` PORT_env() `
284
- - Removed ` print_log_response ` and ` RequestBody::length_is_known `
285
- - Changed ` RequestBody::len ` and ` is_empty ` to return ` Option ` .
286
- - Bugfixes
264
+ - Added:
265
+ - ` log_request_and_response ` and other logging tooling
266
+ - ` Response::ok_200() `
267
+ - ` Response::unauthorized_401() `
268
+ - ` Response::forbidden_403() `
269
+ - ` Response::internal_server_errror_500() `
270
+ - ` Response::not_implemented_501() `
271
+ - ` Response::service_unavailable_503() `
272
+ - ` EventSender::is_connected() `
273
+ - ` PORT_env() `
274
+ - Removed ` print_log_response ` and ` RequestBody::length_is_known `
275
+ - Changed ` RequestBody::len ` and ` is_empty ` to return ` Option ` .
276
+ - Bugfixes
287
277
- v0.1.1 - Add ` EventSender::unconnected ` .
288
278
- v0.1.0 - Rename library to Servlin.
289
279
290
280
# TO DO
291
-
292
281
- Fix limitations above
293
282
- Support [ HEAD] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD )
294
283
responses that have Content-Length set and no body.
295
284
- Add a server-wide limit on upload body size.
296
285
- Limit disk usage for caching uploads.
297
286
- Update ` rust-webserver-comparison.md `
298
- - Add missing data
299
- - Add other servers from < https://www.arewewebyet.org/topics/frameworks/ >
300
- - Rearrange
301
- - Generate geiger reports for each web server
287
+ - Add missing data
288
+ - Add other servers from < https://www.arewewebyet.org/topics/frameworks/ >
289
+ - Rearrange
290
+ - Generate geiger reports for each web server
302
291
303
292
License: MIT OR Apache-2.0
0 commit comments