1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-05-19 16:58:14 +00:00
actix-web/actix-http/src/lib.rs

113 lines
3.2 KiB
Rust
Raw Normal View History

2023-12-16 10:20:28 +00:00
//! HTTP types and services for the Actix ecosystem.
2021-02-13 15:08:43 +00:00
//!
//! ## Crate Features
2023-12-16 10:20:28 +00:00
//!
//! | Feature | Functionality |
//! | ------------------- | ------------------------------------------- |
2022-02-15 20:49:10 +00:00
//! | `http2` | HTTP/2 support via [h2]. |
//! | `openssl` | TLS support via [OpenSSL]. |
//! | `rustls` | TLS support via [rustls]. |
//! | `compress-brotli` | Payload compression support: Brotli. |
//! | `compress-gzip` | Payload compression support: Deflate, Gzip. |
//! | `compress-zstd` | Payload compression support: Zstd. |
//! | `trust-dns` | Use [trust-dns] as the client DNS resolver. |
2021-02-13 15:08:43 +00:00
//!
2022-02-15 20:49:10 +00:00
//! [h2]: https://crates.io/crates/h2
2021-02-13 15:08:43 +00:00
//! [OpenSSL]: https://crates.io/crates/openssl
//! [rustls]: https://crates.io/crates/rustls
//! [trust-dns]: https://crates.io/crates/trust-dns
2020-09-10 13:46:35 +00:00
2021-12-08 06:09:56 +00:00
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![allow(
clippy::type_complexity,
clippy::too_many_arguments,
clippy::borrow_interior_mutable_const
)]
2020-10-30 02:19:56 +00:00
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
2023-02-26 21:55:25 +00:00
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2019-03-26 18:54:35 +00:00
2023-07-17 01:38:12 +00:00
pub use ::http::{uri, uri::Uri, Method, StatusCode, Version};
2021-12-22 07:16:07 +00:00
2019-03-26 18:54:35 +00:00
pub mod body;
mod builder;
mod config;
2022-01-31 17:30:34 +00:00
mod date;
#[cfg(feature = "__compress")]
2019-03-26 22:14:32 +00:00
pub mod encoding;
pub mod error;
2019-03-26 18:54:35 +00:00
mod extensions;
pub mod h1;
2022-01-31 21:22:23 +00:00
#[cfg(feature = "http2")]
pub mod h2;
pub mod header;
2019-03-26 18:54:35 +00:00
mod helpers;
2021-02-11 22:58:35 +00:00
mod http_message;
2022-01-31 17:30:34 +00:00
mod keep_alive;
2019-03-26 18:54:35 +00:00
mod message;
2022-01-31 17:30:34 +00:00
#[cfg(test)]
mod notify_on_drop;
2019-03-26 18:54:35 +00:00
mod payload;
mod requests;
mod responses;
2019-03-26 18:54:35 +00:00
mod service;
2019-11-18 12:42:27 +00:00
pub mod test;
2022-01-31 21:22:23 +00:00
#[cfg(feature = "ws")]
2019-11-18 12:42:27 +00:00
pub mod ws;
2019-03-26 18:54:35 +00:00
#[allow(deprecated)]
2023-07-17 01:38:12 +00:00
pub use self::payload::PayloadStream;
2024-02-03 23:55:01 +00:00
#[cfg(any(
feature = "openssl",
feature = "rustls-0_20",
feature = "rustls-0_21",
feature = "rustls-0_22",
))]
pub use self::service::TlsAcceptorConfig;
2023-07-17 01:38:12 +00:00
pub use self::{
builder::HttpServiceBuilder,
config::ServiceConfig,
error::Error,
extensions::Extensions,
header::ContentEncoding,
http_message::HttpMessage,
keep_alive::KeepAlive,
message::{ConnectionType, Message},
payload::{BoxedPayloadStream, Payload},
requests::{Request, RequestHead, RequestHeadType},
responses::{Response, ResponseBuilder, ResponseHead},
service::HttpService,
};
2019-03-26 18:54:35 +00:00
2021-01-06 18:58:24 +00:00
/// A major HTTP protocol version.
2019-12-02 11:33:11 +00:00
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
2021-01-06 18:58:24 +00:00
#[non_exhaustive]
2019-12-02 11:33:11 +00:00
pub enum Protocol {
Http1,
Http2,
2021-01-06 18:58:24 +00:00
Http3,
2019-12-02 11:33:11 +00:00
}
type ConnectCallback<IO> = dyn Fn(&IO, &mut Extensions);
/// Container for data that extract with ConnectCallback.
2021-01-06 18:52:06 +00:00
///
/// # Implementation Details
/// Uses Option to reduce necessary allocations when merging with request extensions.
2021-10-19 00:32:58 +00:00
#[derive(Default)]
pub(crate) struct OnConnectData(Option<Extensions>);
impl OnConnectData {
2021-01-06 18:52:06 +00:00
/// Construct by calling the on-connect callback with the underlying transport I/O.
2021-12-08 06:01:11 +00:00
pub(crate) fn from_io<T>(io: &T, on_connect_ext: Option<&ConnectCallback<T>>) -> Self {
let ext = on_connect_ext.map(|handler| {
let mut extensions = Extensions::default();
handler(io, &mut extensions);
extensions
});
Self(ext)
}
}