Skip to main content

nitr_http/
lib.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// This file is part of Nitr.
3// See https://nitrweb.com/ for more information
4// Copyright (C) 2024-present Jose Quintana <joseluisq.net>
5
6//! The Nitr HTTP server layer: hyper server and builder, configuration,
7//! and the request/response bridge between HTTP and the Lua runtime.
8
9// Lint policy comes from `[workspace.lints]` in the root Cargo.toml.
10// `unwrap_used`/`expect_used` are denied here (not in the workspace table,
11// which would also hit test and bench targets); unit tests are exempt, and
12// the few documented-invariant `expect()`s carry targeted allows.
13#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used))]
14#![cfg_attr(docsrs, feature(doc_cfg))]
15
16pub(crate) mod app;
17pub(crate) mod compress;
18pub(crate) mod config;
19pub(crate) mod cors;
20pub(crate) mod handler;
21pub(crate) mod health;
22#[cfg(feature = "multipart")]
23pub(crate) mod multipart;
24pub(crate) mod openapi;
25pub(crate) mod protect;
26pub(crate) mod range;
27pub(crate) mod request;
28pub(crate) mod safe_path;
29pub(crate) mod server;
30pub(crate) mod static_files;
31pub(crate) mod stream;
32#[cfg(feature = "tls")]
33pub(crate) mod tls;
34pub(crate) mod validation;
35pub(crate) mod watch;
36
37pub mod testing;
38
39/// Internal functions exposed for the fuzz targets in `fuzz/` only.
40/// Not part of the public API; no stability promise applies here.
41#[doc(hidden)]
42pub mod fuzzing {
43    pub use crate::compress::{Compression, Encoding, parse_accept_encoding};
44    #[cfg(feature = "multipart")]
45    pub use crate::multipart::{
46        consume_for_fuzzing as consume_multipart, resolve_upload_path as resolve_upload,
47        safe_filename,
48    };
49    pub use crate::range::{
50        Resolved, if_range_matches, parse as parse_range, resolve as resolve_range,
51    };
52    pub use crate::request::is_fresh;
53    pub use crate::static_files::{StaticMount, resolve_for_fuzzing as resolve_static};
54    #[cfg(feature = "tls")]
55    pub use crate::tls::{ALPN_PROTOCOLS, Loaded as TlsLoaded, build as build_tls};
56}
57
58/// The hyper `Service` dispatching requests to the Lua pool.
59pub mod service;
60
61pub use config::{
62    CacheConfig, CompressionConfig, Config, CookieSecure, CookiesConfig, CorsConfig,
63    DatabaseConfig, FetchConfig, HealthConfig, LimitsConfig, LogConfig, LogFormat, LuaConfig,
64    MultipartConfig, OpenApiConfig, RateLimitConfig, ShutdownConfig, StaticConfig, StdConfig,
65    SwaggerConfig, TlsConfig,
66};
67pub use server::{Server, ServerBuilder};