1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 16:55:08 +02:00

hide httpmessage mod

This commit is contained in:
Rob Ede
2021-02-11 22:39:54 +00:00
parent 871ca5e4ae
commit 77efc09362
35 changed files with 125 additions and 98 deletions

View File

@ -72,7 +72,7 @@ where
/// Set application data. Application data could be accessed
/// by using `Data<T>` extractor where `T` is data type.
///
/// **Note**: http server accepts an application factory rather than
/// **Note**: HTTP server accepts an application factory rather than
/// an application instance. Http server constructs an application
/// instance for each thread, thus application data must be constructed
/// multiple times. If you want to share data between different
@ -207,7 +207,7 @@ where
)
}
/// Register http service.
/// Register HTTP service.
///
/// Http service is any type that implements `HttpServiceFactory` trait.
///

View File

@ -27,7 +27,7 @@ pub(crate) type FnDataFactory =
///
/// Application data can be accessed by using `Data<T>` extractor where `T` is data type.
///
/// **Note**: http server accepts an application factory rather than an application instance. HTTP
/// **Note**: HTTP server accepts an application factory rather than an application instance. HTTP
/// server constructs an application instance for each thread, thus application data must be
/// constructed multiple times. If you want to share data between different threads, a shareable
/// object should be used, e.g. `Send + Sync`. Application data does not need to be `Send`

View File

@ -176,7 +176,7 @@ impl Guard for NotGuard {
}
}
/// Http method guard
/// HTTP method guard.
#[doc(hidden)]
pub struct MethodGuard(http::Method);
@ -186,52 +186,52 @@ impl Guard for MethodGuard {
}
}
/// Guard to match *GET* http method
/// Guard to match *GET* HTTP method.
pub fn Get() -> MethodGuard {
MethodGuard(http::Method::GET)
}
/// Predicate to match *POST* http method
/// Predicate to match *POST* HTTP method.
pub fn Post() -> MethodGuard {
MethodGuard(http::Method::POST)
}
/// Predicate to match *PUT* http method
/// Predicate to match *PUT* HTTP method.
pub fn Put() -> MethodGuard {
MethodGuard(http::Method::PUT)
}
/// Predicate to match *DELETE* http method
/// Predicate to match *DELETE* HTTP method.
pub fn Delete() -> MethodGuard {
MethodGuard(http::Method::DELETE)
}
/// Predicate to match *HEAD* http method
/// Predicate to match *HEAD* HTTP method.
pub fn Head() -> MethodGuard {
MethodGuard(http::Method::HEAD)
}
/// Predicate to match *OPTIONS* http method
/// Predicate to match *OPTIONS* HTTP method.
pub fn Options() -> MethodGuard {
MethodGuard(http::Method::OPTIONS)
}
/// Predicate to match *CONNECT* http method
/// Predicate to match *CONNECT* HTTP method.
pub fn Connect() -> MethodGuard {
MethodGuard(http::Method::CONNECT)
}
/// Predicate to match *PATCH* http method
/// Predicate to match *PATCH* HTTP method.
pub fn Patch() -> MethodGuard {
MethodGuard(http::Method::PATCH)
}
/// Predicate to match *TRACE* http method
/// Predicate to match *TRACE* HTTP method.
pub fn Trace() -> MethodGuard {
MethodGuard(http::Method::TRACE)
}
/// Predicate to match specified http method
/// Predicate to match specified HTTP method.
pub fn Method(method: http::Method) -> MethodGuard {
MethodGuard(method)
}

View File

@ -62,7 +62,7 @@ impl HttpRequest {
}
/// This method returns mutable reference to the request head.
/// panics if multiple references of http request exists.
/// panics if multiple references of HTTP request exists.
#[inline]
pub(crate) fn head_mut(&mut self) -> &mut RequestHead {
&mut Rc::get_mut(&mut self.inner).unwrap().head
@ -202,12 +202,14 @@ impl HttpRequest {
&self.app_state().rmap()
}
/// Peer socket address
/// Peer socket address.
///
/// Peer address is actual socket address, if proxy is used in front of
/// actix http server, then peer address would be address of this proxy.
/// Peer address is the directly connected peer's socket address. If a proxy is used in front of
/// the Actix Web server, then it would be address of this proxy.
///
/// To get client connection information `.connection_info()` should be used.
///
/// Will only return None when called in unit tests.
#[inline]
pub fn peer_addr(&self) -> Option<net::SocketAddr> {
self.head().peer_addr

View File

@ -40,7 +40,7 @@ struct Config {
/// An HTTP Server.
///
/// Create new http server with application factory.
/// Create new HTTP server with application factory.
///
/// ```rust,no_run
/// use actix_web::{web, App, HttpResponse, HttpServer};
@ -86,7 +86,7 @@ where
S::Service: 'static,
B: MessageBody + 'static,
{
/// Create new http server with application factory
/// Create new HTTP server with application factory
pub fn new(factory: F) -> Self {
HttpServer {
factory,
@ -131,8 +131,7 @@ where
/// Set number of workers to start.
///
/// By default http server uses number of available logical cpu as threads
/// count.
/// By default, server uses number of available logical CPU as thread count.
pub fn workers(mut self, num: usize) -> Self {
self.builder = self.builder.workers(num);
self
@ -257,7 +256,7 @@ where
/// Get addresses of bound sockets and the scheme for it.
///
/// This is useful when the server is bound from different sources
/// with some sockets listening on http and some listening on https
/// with some sockets listening on HTTP and some listening on HTTPS
/// and the user should be presented with an enumeration of which
/// socket requires which protocol.
pub fn addrs_with_scheme(&self) -> Vec<(net::SocketAddr, &str)> {
@ -610,7 +609,7 @@ where
{
/// Start listening for incoming connections.
///
/// This method starts number of http workers in separate threads.
/// This method starts number of HTTP workers in separate threads.
/// For each address this method starts separate thread which does
/// `accept()` in a loop.
///

View File

@ -164,12 +164,14 @@ impl ServiceRequest {
}
}
/// Peer socket address
/// Peer socket address.
///
/// Peer address is actual socket address, if proxy is used in front of
/// actix http server, then peer address would be address of this proxy.
/// Peer address is the directly connected peer's socket address. If a proxy is used in front of
/// the Actix Web server, then it would be address of this proxy.
///
/// To get client connection information `ConnectionInfo` should be used.
///
/// Will only return None when called in unit tests.
#[inline]
pub fn peer_addr(&self) -> Option<net::SocketAddr> {
self.head().peer_addr

View File

@ -851,13 +851,13 @@ impl TestServerConfig {
}
}
/// Start http/1.1 server only
/// Start HTTP/1.1 server only
pub fn h1(mut self) -> Self {
self.tp = HttpVer::Http1;
self
}
/// Start http/2 server only
/// Start HTTP/2 server only
pub fn h2(mut self) -> Self {
self.tp = HttpVer::Http2;
self
@ -956,7 +956,7 @@ impl TestServer {
self.client.options(self.url(path.as_ref()).as_str())
}
/// Connect to test http server
/// Connect to test HTTP server
pub fn request<S: AsRef<str>>(&self, method: Method, path: S) -> ClientRequest {
self.client.request(method, path.as_ref())
}
@ -990,7 +990,7 @@ impl TestServer {
self.ws_at("/").await
}
/// Gracefully stop http server
/// Gracefully stop HTTP server
pub async fn stop(self) {
self.server.stop(true).await;
self.system.stop();
@ -1006,7 +1006,7 @@ impl Drop for TestServer {
#[cfg(test)]
mod tests {
use actix_http::httpmessage::HttpMessage;
use actix_http::HttpMessage;
use serde::{Deserialize, Serialize};
use std::time::SystemTime;