1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-30 16:34:26 +02:00

re-export rt in web and add main macro (#1575)

This commit is contained in:
Rob Ede
2020-06-22 20:09:48 +01:00
committed by GitHub
parent c11052f826
commit a70e599ff5
18 changed files with 71 additions and 29 deletions

View File

@ -42,6 +42,7 @@ pub struct App<T, B> {
impl App<AppEntry, Body> {
/// Create application builder. Application can be configured with a builder-like pattern.
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
let fref = Rc::new(RefCell::new(None));
App {

View File

@ -25,7 +25,7 @@ impl ConnectionInfo {
Ref::map(req.extensions(), |e| e.get().unwrap())
}
#[allow(clippy::cognitive_complexity)]
#[allow(clippy::cognitive_complexity, clippy::borrow_interior_mutable_const)]
fn new(req: &RequestHead, cfg: &AppConfig) -> ConnectionInfo {
let mut host = None;
let mut scheme = None;

View File

@ -1,18 +1,11 @@
#![warn(rust_2018_idioms, warnings)]
#![allow(
clippy::needless_doctest_main,
clippy::type_complexity,
clippy::borrow_interior_mutable_const
)]
#![allow(clippy::needless_doctest_main, clippy::type_complexity)]
//! Actix web is a small, pragmatic, and extremely fast web framework
//! for Rust.
//!
//! ## Example
//!
//! The `#[actix_rt::main]` macro in the example below is provided by the Actix runtime
//! crate, [`actix-rt`](https://crates.io/crates/actix-rt). You will need to include
//! `actix-rt` in your dependencies for it to run.
//!
//! ```rust,no_run
//! use actix_web::{web, App, Responder, HttpServer};
//!
@ -20,7 +13,7 @@
//! format!("Hello {}! id:{}", info.0, info.1)
//! }
//!
//! #[actix_rt::main]
//! #[actix_web::main]
//! async fn main() -> std::io::Result<()> {
//! HttpServer::new(|| App::new().service(
//! web::resource("/{name}/{id}/index.html").to(index))
@ -80,9 +73,7 @@
//! * `compress` - enables content encoding compression support (default enabled)
//! * `openssl` - enables ssl support via `openssl` crate, supports `http/2`
//! * `rustls` - enables ssl support via `rustls` crate, supports `http/2`
//! * `secure-cookies` - enables secure cookies support, includes `ring` crate as
//! dependency
#![allow(clippy::type_complexity, clippy::new_without_default)]
//! * `secure-cookies` - enables secure cookies support
mod app;
mod app_service;
@ -106,13 +97,12 @@ pub mod test;
mod types;
pub mod web;
#[doc(hidden)]
pub use actix_web_codegen::*;
pub use actix_rt as rt;
// re-export for convenience
pub use actix_http::Response as HttpResponse;
pub use actix_http::{body, cookie, http, Error, HttpMessage, ResponseError, Result};
pub use actix_macros::{main, test as test_rt};
pub use crate::app::App;
pub use crate::extract::FromRequest;
@ -230,6 +220,7 @@ pub mod client {
//! println!("Response: {:?}", response);
//! }
//! ```
pub use awc::error::{
ConnectError, InvalidUrl, PayloadError, SendRequestError, WsClientError,
};

View File

@ -90,6 +90,7 @@ where
self.service.poll_ready(cx)
}
#[allow(clippy::borrow_interior_mutable_const)]
fn call(&mut self, req: ServiceRequest) -> Self::Future {
// negotiate content-encoding
let encoding = if let Some(val) = req.headers().get(&ACCEPT_ENCODING) {

View File

@ -128,6 +128,7 @@ where
self.service.poll_ready(cx)
}
#[allow(clippy::borrow_interior_mutable_const)]
fn call(&mut self, req: ServiceRequest) -> Self::Future {
let inner = self.inner.clone();
let fut = self.service.call(req);

View File

@ -478,7 +478,7 @@ impl FormatText {
}
FormatText::RemoteAddr => {
let s = if let Some(ref peer) = req.connection_info().remote_addr() {
FormatText::Str(peer.to_string())
FormatText::Str((*peer).to_string())
} else {
FormatText::Str("-".to_string())
};

View File

@ -46,6 +46,7 @@ pub struct Route {
impl Route {
/// Create new route which matches any request.
#[allow(clippy::new_without_default)]
pub fn new() -> Route {
Route {
service: Box::new(RouteNewService::new(Extract::new(Handler::new(|| {

View File

@ -252,6 +252,7 @@ pub struct UrlEncoded<U> {
fut: Option<LocalBoxFuture<'static, Result<U, UrlencodedError>>>,
}
#[allow(clippy::borrow_interior_mutable_const)]
impl<U> UrlEncoded<U> {
/// Create a new future to URL encode a request
pub fn new(req: &HttpRequest, payload: &mut Payload) -> UrlEncoded<U> {

View File

@ -319,6 +319,7 @@ where
U: DeserializeOwned + 'static,
{
/// Create `JsonBody` for request.
#[allow(clippy::borrow_interior_mutable_const)]
pub fn new(
req: &HttpRequest,
payload: &mut Payload,

View File

@ -315,6 +315,7 @@ pub struct HttpMessageBody {
impl HttpMessageBody {
/// Create `MessageBody` for request.
#[allow(clippy::borrow_interior_mutable_const)]
pub fn new(req: &HttpRequest, payload: &mut dev::Payload) -> HttpMessageBody {
let mut len = None;
if let Some(l) = req.headers().get(&header::CONTENT_LENGTH) {