1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-26 03:21:08 +00:00

remove crate level clippy allows

This commit is contained in:
Rob Ede 2021-12-25 04:53:51 +00:00
parent 5860fe5381
commit 2e493cf791
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
10 changed files with 61 additions and 70 deletions

View file

@ -122,9 +122,10 @@ impl<T> App<T> {
self.app_data(Data::new(data))
}
/// Add application data factory. This function is similar to `.data()` but it accepts a
/// "data factory". Data values are constructed asynchronously during application
/// initialization, before the server starts accepting requests.
/// Add application data factory that resolves asynchronously.
///
/// Data items are constructed during application initialization, before the server starts
/// accepting requests.
pub fn data_factory<F, Out, D, E>(mut self, data: F) -> Self
where
F: Fn() -> Out + 'static,
@ -150,6 +151,7 @@ impl<T> App<T> {
}
.boxed_local()
}));
self
}
@ -200,11 +202,9 @@ impl<T> App<T> {
/// "Welcome!"
/// }
///
/// fn main() {
/// let app = App::new()
/// .route("/test1", web::get().to(index))
/// .route("/test2", web::post().to(|| HttpResponse::MethodNotAllowed()));
/// }
/// ```
pub fn route(self, path: &str, mut route: Route) -> Self {
self.service(
@ -243,13 +243,11 @@ impl<T> App<T> {
/// "Welcome!"
/// }
///
/// fn main() {
/// let app = App::new()
/// .service(
/// web::resource("/index.html").route(web::get().to(index)))
/// .default_service(
/// web::route().to(|| HttpResponse::NotFound()));
/// }
/// ```
///
/// It is also possible to use static files as default service.
@ -257,14 +255,12 @@ impl<T> App<T> {
/// ```
/// use actix_web::{web, App, HttpResponse};
///
/// fn main() {
/// let app = App::new()
/// .service(
/// web::resource("/index.html").to(|| HttpResponse::Ok()))
/// .default_service(
/// web::to(|| HttpResponse::NotFound())
/// );
/// }
/// ```
pub fn default_service<F, U>(mut self, svc: F) -> Self
where

View file

@ -236,6 +236,7 @@ where
}
pub struct AppRoutingFactory {
#[allow(clippy::type_complexity)]
services: Rc<
[(
ResourceDef,

View file

@ -24,6 +24,7 @@ pub struct AppService {
config: AppConfig,
root: bool,
default: Rc<HttpNewService>,
#[allow(clippy::type_complexity)]
services: Vec<(
ResourceDef,
HttpNewService,
@ -48,6 +49,7 @@ impl AppService {
self.root
}
#[allow(clippy::type_complexity)]
pub(crate) fn into_services(
self,
) -> (

View file

@ -15,14 +15,12 @@
//! ```
//! use actix_web::{web, http, dev, guard, App, HttpResponse};
//!
//! fn main() {
//! App::new().service(web::resource("/index.html").route(
//! web::route()
//! .guard(guard::Post())
//! .guard(guard::fn_guard(|head| head.method == http::Method::GET))
//! .to(|| HttpResponse::MethodNotAllowed()))
//! );
//! }
//! ```
#![allow(non_snake_case)]
@ -53,7 +51,6 @@ impl Guard for Rc<dyn Guard> {
/// ```
/// use actix_web::{guard, web, App, HttpResponse};
///
/// fn main() {
/// App::new().service(web::resource("/index.html").route(
/// web::route()
/// .guard(
@ -62,7 +59,6 @@ impl Guard for Rc<dyn Guard> {
/// .contains_key("content-type")))
/// .to(|| HttpResponse::MethodNotAllowed()))
/// );
/// }
/// ```
pub fn fn_guard<F>(f: F) -> impl Guard
where
@ -96,13 +92,11 @@ where
/// ```
/// use actix_web::{web, guard, App, HttpResponse};
///
/// fn main() {
/// App::new().service(web::resource("/index.html").route(
/// web::route()
/// .guard(guard::Any(guard::Get()).or(guard::Post()))
/// .to(|| HttpResponse::MethodNotAllowed()))
/// );
/// }
/// ```
pub fn Any<F: Guard + 'static>(guard: F) -> AnyGuard {
AnyGuard(vec![Box::new(guard)])
@ -135,14 +129,12 @@ impl Guard for AnyGuard {
/// ```
/// use actix_web::{guard, web, App, HttpResponse};
///
/// fn main() {
/// App::new().service(web::resource("/index.html").route(
/// web::route()
/// .guard(
/// guard::All(guard::Get()).and(guard::Header("content-type", "text/plain")))
/// .to(|| HttpResponse::MethodNotAllowed()))
/// );
/// }
/// ```
pub fn All<F: Guard + 'static>(guard: F) -> AllGuard {
AllGuard(vec![Box::new(guard)])

View file

@ -31,8 +31,8 @@ use crate::{
/// The first thing to note is that [`FromRequest`] is implemented for tuples (up to 12 in length).
///
/// Secondly, the `Handler` trait is implemented for functions (up to an [arity] of 12) in a way
/// that aligns their parameter positions with a corresponding tuple of types (becoming the `T` type
/// parameter in this trait's implementation).
/// that aligns their parameter positions with a corresponding tuple of types (becoming the `Args`
/// type parameter for this trait).
///
/// Thanks to Rust's type system, Actix Web can infer the function parameter types. During the
/// extraction step, the parameter types are described as a tuple type, [`from_request`] is run on
@ -78,12 +78,12 @@ use crate::{
/// [arity]: https://en.wikipedia.org/wiki/Arity
/// [`from_request`]: FromRequest::from_request
/// [on_unimpl]: https://github.com/rust-lang/rust/issues/29628
pub trait Handler<T, R>: Clone + 'static
pub trait Handler<Args, R>: Clone + 'static
where
R: Future,
R::Output: Responder,
{
fn call(&self, args: T) -> R;
fn call(&self, args: Args) -> R;
}
pub(crate) fn handler_service<F, Args, R>(handler: F) -> BoxedHttpServiceFactory

View file

@ -66,7 +66,6 @@
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![allow(clippy::needless_doctest_main, clippy::type_complexity)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]

View file

@ -113,6 +113,7 @@ where
{
type Response = ServiceResponse<EitherBody<Encoder<B>>>;
type Error = Error;
#[allow(clippy::type_complexity)]
type Future = Either<CompressResponse<S, B>, Ready<Result<Self::Response, Self::Error>>>;
actix_service::forward_ready!(service);

View file

@ -131,7 +131,6 @@ where
/// ```
/// use actix_web::{web, guard, App, HttpResponse};
///
/// fn main() {
/// let app = App::new().service(
/// web::resource("/").route(
/// web::route()
@ -139,7 +138,6 @@ where
/// .guard(guard::Header("Content-Type", "text/plain"))
/// .to(|| HttpResponse::Ok()))
/// );
/// }
/// ```
///
/// Multiple routes could be added to a resource. Resource object uses

View file

@ -469,6 +469,7 @@ where
}
pub struct ScopeFactory {
#[allow(clippy::type_complexity)]
services: Rc<
[(
ResourceDef,

View file

@ -63,6 +63,7 @@ where
backlog: u32,
sockets: Vec<Socket>,
builder: ServerBuilder,
#[allow(clippy::type_complexity)]
on_connect_fn: Option<Arc<dyn Fn(&dyn Any, &mut Extensions) + Send + Sync>>,
_phantom: PhantomData<(S, B)>,
}