1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-10 17:29:36 +00:00

cleanup doc strings and clippy warnings

This commit is contained in:
Nikolay Kim 2019-03-16 21:35:02 -07:00
parent e396c90c9e
commit 4a4826b23a
7 changed files with 43 additions and 26 deletions

View file

@ -148,7 +148,7 @@ where
}
/// Register a request modifier. It can modify any request parameters
/// including payload stream.
/// including payload stream type.
pub fn chain<C, F, P1>(
self,
chain: C,
@ -211,6 +211,14 @@ where
}
/// Register http service.
///
/// Http service is any type that implements `HttpServiceFactory` trait.
///
/// Actix web provides several services implementations:
///
/// * *Resource* is an entry in resource table which corresponds to requested URL.
/// * *Scope* is a set of resources with common root path.
/// * "StaticFiles" is a service for static files support
pub fn service<F>(self, service: F) -> AppRouter<T, P, Body, AppEntry<P>>
where
F: HttpServiceFactory<P> + 'static,
@ -301,7 +309,7 @@ where
///
/// Actix web provides several services implementations:
///
/// * *Resource* is an entry in route table which corresponds to requested URL.
/// * *Resource* is an entry in resource table which corresponds to requested URL.
/// * *Scope* is a set of resources with common root path.
/// * "StaticFiles" is a service for static files support
pub fn service<F>(mut self, factory: F) -> Self
@ -354,9 +362,6 @@ where
}
/// Default resource to be used if no matching route could be found.
///
/// Default resource works with resources only and does not work with
/// custom services.
pub fn default_resource<F, U>(mut self, f: F) -> Self
where
F: FnOnce(Resource<P>) -> Resource<P, U>,

View file

@ -25,7 +25,7 @@ impl ConnectionInfo {
Ref::map(req.extensions(), |e| e.get().unwrap())
}
#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
#[allow(clippy::cyclomatic_complexity)]
fn new(req: &RequestHead, cfg: &AppConfig) -> ConnectionInfo {
let mut host = None;
let mut scheme = None;
@ -123,10 +123,10 @@ impl ConnectionInfo {
}
ConnectionInfo {
peer,
scheme: scheme.unwrap_or("http").to_owned(),
host: host.unwrap_or("localhost").to_owned(),
remote: remote.map(|s| s.to_owned()),
peer: peer,
}
}

View file

@ -1,4 +1,4 @@
#![allow(clippy::type_complexity)]
#![allow(clippy::type_complexity, clippy::new_without_default)]
mod app;
mod app_service;
@ -84,6 +84,7 @@ pub mod web {
pub use actix_http::Response as HttpResponse;
pub use bytes::{Bytes, BytesMut};
use crate::error::{BlockingError, Error};
use crate::extract::FromRequest;
use crate::handler::{AsyncFactory, Factory};
use crate::resource::Resource;
@ -92,7 +93,6 @@ pub mod web {
use crate::scope::Scope;
pub use crate::data::{Data, RouteData};
pub use crate::error::{BlockingError, Error};
pub use crate::extract::{Form, Json, Path, Payload, Query};
pub use crate::extract::{FormConfig, JsonConfig, PayloadConfig};
pub use crate::request::HttpRequest;

View file

@ -21,7 +21,7 @@ type HttpService<P> = BoxedService<ServiceRequest<P>, ServiceResponse, Error>;
type HttpNewService<P> =
BoxedNewService<(), ServiceRequest<P>, ServiceResponse, Error, ()>;
/// *Resource* is an entry in route table which corresponds to requested URL.
/// *Resource* is an entry in resources table which corresponds to requested URL.
///
/// Resource in turn has at least one route.
/// Route consists of an handlers objects and list of guards
@ -132,7 +132,8 @@ where
/// }
/// ```
///
/// Multiple routes could be added to a resource.
/// Multiple routes could be added to a resource. Resource object uses
/// match guards for route selection.
///
/// ```rust
/// use actix_web::{web, guard, App, HttpResponse};
@ -220,11 +221,11 @@ where
self
}
/// Register a resource middleware
/// Register a resource middleware.
///
/// This is similar to `App's` middlewares, but
/// middleware is not allowed to change response type (i.e modify response's body).
/// Middleware get invoked on resource level.
/// This is similar to `App's` middlewares, but middleware get invoked on resource level.
/// Resource level middlewares are not allowed to change response
/// type (i.e modify response's body).
pub fn middleware<M, F>(
self,
mw: F,

View file

@ -62,7 +62,7 @@ impl<P: 'static> Route<P> {
}
pub(crate) fn finish(mut self) -> Self {
*self.data_ref.borrow_mut() = self.data.take().map(|e| Rc::new(e));
*self.data_ref.borrow_mut() = self.data.take().map(Rc::new);
self
}

View file

@ -26,7 +26,7 @@ type HttpNewService<P> =
BoxedNewService<(), ServiceRequest<P>, ServiceResponse, Error, ()>;
type BoxedResponse = Box<Future<Item = ServiceResponse, Error = Error>>;
/// Resources scope
/// Resources scope.
///
/// Scope is a set of resources with common root path.
/// Scopes collect multiple paths under a common path prefix.
@ -114,7 +114,15 @@ where
self
}
/// Create nested service.
/// Register http service.
///
/// This is similar to `App's` service registration.
///
/// Actix web provides several services implementations:
///
/// * *Resource* is an entry in resource table which corresponds to requested URL.
/// * *Scope* is a set of resources with common root path.
/// * "StaticFiles" is a service for static files support
///
/// ```rust
/// use actix_web::{web, App, HttpRequest};
@ -145,7 +153,7 @@ where
/// Configure route for a specific path.
///
/// This is a simplified version of the `Scope::service()` method.
/// This method can not be could multiple times, in that case
/// This method can be called multiple times, in that case
/// multiple resources with one route would be registered for same resource path.
///
/// ```rust
@ -172,6 +180,8 @@ where
}
/// Default resource to be used if no matching route could be found.
///
/// If default resource is not registered, app's default resource is being used.
pub fn default_resource<F, U>(mut self, f: F) -> Self
where
F: FnOnce(Resource<P>) -> Resource<P, U>,
@ -190,11 +200,11 @@ where
self
}
/// Register a scope middleware
/// Register a scope level middleware.
///
/// This is similar to `App's` middlewares, but
/// middleware is not allowed to change response type (i.e modify response's body).
/// Middleware get invoked on scope level.
/// This is similar to `App's` middlewares, but middleware get invoked on scope level.
/// Scope level middlewares are not allowed to change response
/// type (i.e modify response's body).
pub fn middleware<M, F>(
self,
mw: F,
@ -322,7 +332,7 @@ impl<P: 'static> NewService for ScopeFactory<P> {
}
}
/// Create app service
/// Create scope service
#[doc(hidden)]
pub struct ScopeFactoryResponse<P> {
fut: Vec<CreateScopeServiceItem<P>>,

View file

@ -50,7 +50,7 @@ pub fn run_on<F, I, E>(f: F) -> Result<I, E>
where
F: Fn() -> Result<I, E>,
{
RT.with(move |rt| rt.borrow_mut().block_on(lazy(|| f())))
RT.with(move |rt| rt.borrow_mut().block_on(lazy(f)))
}
/// This method accepts application builder instance, and constructs
@ -169,6 +169,7 @@ impl Default for TestRequest {
}
}
#[allow(clippy::wrong_self_convention)]
impl TestRequest {
/// Create TestRequest and set request uri
pub fn with_uri(path: &str) -> TestRequest {
@ -254,7 +255,7 @@ impl TestRequest {
}
/// Set cookie for this request
pub fn cookie<'a>(mut self, cookie: Cookie<'a>) -> Self {
pub fn cookie(mut self, cookie: Cookie) -> Self {
self.req.cookie(cookie);
self
}