1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-12-04 20:31:55 +01:00
actix-web/actix-http/src/lib.rs

113 lines
3.2 KiB
Rust
Raw Normal View History

2023-12-16 11:20:28 +01:00
//! HTTP types and services for the Actix ecosystem.
2021-02-13 16:08:43 +01:00
//!
//! ## Crate Features
2023-12-16 11:20:28 +01:00
//!
//! | Feature | Functionality |
//! | ------------------- | ------------------------------------------- |
2022-02-15 21:49:10 +01: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 16:08:43 +01:00
//!
2022-02-15 21:49:10 +01:00
//! [h2]: https://crates.io/crates/h2
2021-02-13 16:08:43 +01:00
//! [OpenSSL]: https://crates.io/crates/openssl
//! [rustls]: https://crates.io/crates/rustls
//! [trust-dns]: https://crates.io/crates/trust-dns
2020-09-10 15:46:35 +02:00
2021-12-08 07:09:56 +01: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 03:19:56 +01:00
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
2023-02-26 22:55:25 +01:00
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2019-03-26 19:54:35 +01:00
2023-07-17 03:38:12 +02:00
pub use ::http::{uri, uri::Uri, Method, StatusCode, Version};
2021-12-22 08:16:07 +01:00
2019-03-26 19:54:35 +01:00
pub mod body;
mod builder;
mod config;
2022-01-31 18:30:34 +01:00
mod date;
#[cfg(feature = "__compress")]
2019-03-26 23:14:32 +01:00
pub mod encoding;
pub mod error;
2019-03-26 19:54:35 +01:00
mod extensions;
pub mod h1;
2022-01-31 22:22:23 +01:00
#[cfg(feature = "http2")]
pub mod h2;
pub mod header;
2019-03-26 19:54:35 +01:00
mod helpers;
2021-02-11 23:58:35 +01:00
mod http_message;
2022-01-31 18:30:34 +01:00
mod keep_alive;
2019-03-26 19:54:35 +01:00
mod message;
2022-01-31 18:30:34 +01:00
#[cfg(test)]
mod notify_on_drop;
2019-03-26 19:54:35 +01:00
mod payload;
mod requests;
mod responses;
2019-03-26 19:54:35 +01:00
mod service;
2019-11-18 13:42:27 +01:00
pub mod test;
2022-01-31 22:22:23 +01:00
#[cfg(feature = "ws")]
2019-11-18 13:42:27 +01:00
pub mod ws;
2019-03-26 19:54:35 +01:00
#[allow(deprecated)]
2023-07-17 03:38:12 +02:00
pub use self::payload::PayloadStream;
2024-02-04 00:55:01 +01: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 03:38:12 +02: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 19:54:35 +01:00
2021-01-06 19:58:24 +01:00
/// A major HTTP protocol version.
2019-12-02 12:33:11 +01:00
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
2021-01-06 19:58:24 +01:00
#[non_exhaustive]
2019-12-02 12:33:11 +01:00
pub enum Protocol {
Http1,
Http2,
2021-01-06 19:58:24 +01:00
Http3,
2019-12-02 12:33:11 +01:00
}
type ConnectCallback<IO> = dyn Fn(&IO, &mut Extensions);
/// Container for data that extract with ConnectCallback.
2021-01-06 19:52:06 +01:00
///
/// # Implementation Details
/// Uses Option to reduce necessary allocations when merging with request extensions.
2021-10-19 02:32:58 +02:00
#[derive(Default)]
pub(crate) struct OnConnectData(Option<Extensions>);
impl OnConnectData {
2021-01-06 19:52:06 +01:00
/// Construct by calling the on-connect callback with the underlying transport I/O.
2021-12-08 07:01:11 +01: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)
}
}