mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 16:02:59 +01:00
docs(application): Formatting & spelling fixes in module docs
This commit is contained in:
parent
38063b9873
commit
b2a43a3c8d
@ -140,7 +140,7 @@ pub struct App<S=()> {
|
|||||||
impl App<()> {
|
impl App<()> {
|
||||||
|
|
||||||
/// Create application with empty state. Application can
|
/// Create application with empty state. Application can
|
||||||
/// be configured with builder-like pattern.
|
/// be configured with a builder-like pattern.
|
||||||
pub fn new() -> App<()> {
|
pub fn new() -> App<()> {
|
||||||
App {
|
App {
|
||||||
parts: Some(ApplicationParts {
|
parts: Some(ApplicationParts {
|
||||||
@ -166,11 +166,11 @@ impl Default for App<()> {
|
|||||||
|
|
||||||
impl<S> App<S> where S: 'static {
|
impl<S> App<S> where S: 'static {
|
||||||
|
|
||||||
/// Create application with specific state. Application can be
|
/// Create application with specified state. Application can be
|
||||||
/// configured with builder-like pattern.
|
/// configured with a builder-like pattern.
|
||||||
///
|
///
|
||||||
/// State is shared with all resources within same application and could be
|
/// State is shared with all resources within same application and
|
||||||
/// accessed with `HttpRequest::state()` method.
|
/// could be accessed with `HttpRequest::state()` method.
|
||||||
pub fn with_state(state: S) -> App<S> {
|
pub fn with_state(state: S) -> App<S> {
|
||||||
App {
|
App {
|
||||||
parts: Some(ApplicationParts {
|
parts: Some(ApplicationParts {
|
||||||
@ -187,18 +187,24 @@ impl<S> App<S> where S: 'static {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set application prefix
|
/// Set application prefix.
|
||||||
///
|
///
|
||||||
/// Only requests that matches application's prefix get processed by this application.
|
/// Only requests that match the application's prefix get
|
||||||
/// Application prefix always contains leading "/" slash. If supplied prefix
|
/// processed by this application.
|
||||||
/// does not contain leading slash, it get inserted. Prefix should
|
|
||||||
/// consists valid path segments. i.e for application with
|
|
||||||
/// prefix `/app` any request with following paths `/app`, `/app/` or `/app/test`
|
|
||||||
/// would match, but path `/application` would not match.
|
|
||||||
///
|
///
|
||||||
/// In the following example only requests with "/app/" path prefix
|
/// The application prefix always contains a leading slash (`/`).
|
||||||
/// get handled. Request with path "/app/test/" would be handled,
|
/// If the supplied prefix does not contain leading slash, it is
|
||||||
/// but request with path "/application" or "/other/..." would return *NOT FOUND*
|
/// inserted.
|
||||||
|
///
|
||||||
|
/// Prefix should consist of valid path segments. i.e for an
|
||||||
|
/// application with the prefix `/app` any request with the paths
|
||||||
|
/// `/app`, `/app/` or `/app/test` would match, but the path
|
||||||
|
/// `/application` would not.
|
||||||
|
///
|
||||||
|
/// In the following example only requests with an `/app/` path
|
||||||
|
/// prefix get handled. Requests with path `/app/test/` would be
|
||||||
|
/// handled, while requests with the paths `/application` or
|
||||||
|
/// `/other/...` would return `NOT FOUND`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # extern crate actix_web;
|
/// # extern crate actix_web;
|
||||||
@ -226,12 +232,14 @@ impl<S> App<S> where S: 'static {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configure route for specific path.
|
/// Configure route for a specific path.
|
||||||
///
|
///
|
||||||
/// This is simplified version of `App::resource()` method.
|
/// This is a simplified version of the `App::resource()` method.
|
||||||
/// Handler function needs to accept one request extractor argument.
|
/// Handler functions need to accept one request extractor
|
||||||
/// This method could be called multiple times, in that case multiple routes
|
/// argument.
|
||||||
/// would be registered for same resource path.
|
///
|
||||||
|
/// This method could be called multiple times, in that case
|
||||||
|
/// multiple routes would be registered for same resource path.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # extern crate actix_web;
|
/// # extern crate actix_web;
|
||||||
@ -272,23 +280,25 @@ impl<S> App<S> where S: 'static {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configure resource for specific path.
|
/// Configure resource for a specific path.
|
||||||
///
|
///
|
||||||
/// Resource may have variable path also. For instance, a resource with
|
/// Resources may have variable path segments. For example, a
|
||||||
/// the path */a/{name}/c* would match all incoming requests with paths
|
/// resource with the path `/a/{name}/c` would match all incoming
|
||||||
/// such as */a/b/c*, */a/1/c*, and */a/etc/c*.
|
/// requests with paths such as `/a/b/c`, `/a/1/c`, or `/a/etc/c`.
|
||||||
///
|
///
|
||||||
/// A variable part is specified in the form `{identifier}`, where
|
/// A variable segment is specified in the form `{identifier}`,
|
||||||
/// the identifier can be used later in a request handler to access the matched
|
/// where the identifier can be used later in a request handler to
|
||||||
/// value for that part. This is done by looking up the identifier
|
/// access the matched value for that segment. This is done by
|
||||||
/// in the `Params` object returned by `HttpRequest.match_info()` method.
|
/// looking up the identifier in the `Params` object returned by
|
||||||
|
/// `HttpRequest.match_info()` method.
|
||||||
///
|
///
|
||||||
/// By default, each part matches the regular expression `[^{}/]+`.
|
/// By default, each segment matches the regular expression `[^{}/]+`.
|
||||||
///
|
///
|
||||||
/// You can also specify a custom regex in the form `{identifier:regex}`:
|
/// You can also specify a custom regex in the form `{identifier:regex}`:
|
||||||
///
|
///
|
||||||
/// For instance, to route Get requests on any route matching `/users/{userid}/{friend}` and
|
/// For instance, to route `GET`-requests on any route matching
|
||||||
/// store userid and friend in the exposed Params object:
|
/// `/users/{userid}/{friend}` and store `userid` and `friend` in
|
||||||
|
/// the exposed `Params` object:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # extern crate actix_web;
|
/// # extern crate actix_web;
|
||||||
@ -318,7 +328,8 @@ impl<S> App<S> where S: 'static {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Default resource is used if no matched route could be found.
|
/// Default resource to be used if no matching route could be
|
||||||
|
/// found.
|
||||||
pub fn default_resource<F, R>(mut self, f: F) -> App<S>
|
pub fn default_resource<F, R>(mut self, f: F) -> App<S>
|
||||||
where F: FnOnce(&mut ResourceHandler<S>) -> R + 'static
|
where F: FnOnce(&mut ResourceHandler<S>) -> R + 'static
|
||||||
{
|
{
|
||||||
@ -339,11 +350,11 @@ impl<S> App<S> where S: 'static {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register external resource.
|
/// Register an external resource.
|
||||||
///
|
///
|
||||||
/// External resources are useful for URL generation purposes only and
|
/// External resources are useful for URL generation purposes only
|
||||||
/// are never considered for matching at request time.
|
/// and are never considered for matching at request time. Calls to
|
||||||
/// Call to `HttpRequest::url_for()` will work as expected.
|
/// `HttpRequest::url_for()` will work as expected.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # extern crate actix_web;
|
/// # extern crate actix_web;
|
||||||
@ -380,9 +391,10 @@ impl<S> App<S> where S: 'static {
|
|||||||
|
|
||||||
/// Configure handler for specific path prefix.
|
/// Configure handler for specific path prefix.
|
||||||
///
|
///
|
||||||
/// Path prefix consists valid path segments. i.e for prefix `/app`
|
/// A path prefix consists of valid path segments, i.e for the
|
||||||
/// any request with following paths `/app`, `/app/` or `/app/test`
|
/// prefix `/app` any request with the paths `/app`, `/app/` or
|
||||||
/// would match, but path `/application` would not match.
|
/// `/app/test` would match, but the path `/application` would
|
||||||
|
/// not.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # extern crate actix_web;
|
/// # extern crate actix_web;
|
||||||
@ -408,18 +420,19 @@ impl<S> App<S> where S: 'static {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register a middleware
|
/// Register a middleware.
|
||||||
pub fn middleware<M: Middleware<S>>(mut self, mw: M) -> App<S> {
|
pub fn middleware<M: Middleware<S>>(mut self, mw: M) -> App<S> {
|
||||||
self.parts.as_mut().expect("Use after finish")
|
self.parts.as_mut().expect("Use after finish")
|
||||||
.middlewares.push(Box::new(mw));
|
.middlewares.push(Box::new(mw));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run external configuration as part of application building process
|
/// Run external configuration as part of the application building
|
||||||
|
/// process
|
||||||
///
|
///
|
||||||
/// This function is useful for moving part of configuration to a different
|
/// This function is useful for moving parts of configuration to a
|
||||||
/// module or event library. For example we can move some of the resources
|
/// different module or event library. For example we can move
|
||||||
/// configuration to different module.
|
/// some of the resources' configuration to different module.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # extern crate actix_web;
|
/// # extern crate actix_web;
|
||||||
@ -447,7 +460,7 @@ impl<S> App<S> where S: 'static {
|
|||||||
cfg(self)
|
cfg(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finish application configuration and create HttpHandler object
|
/// Finish application configuration and create `HttpHandler` object.
|
||||||
pub fn finish(&mut self) -> HttpApplication<S> {
|
pub fn finish(&mut self) -> HttpApplication<S> {
|
||||||
let parts = self.parts.take().expect("Use after finish");
|
let parts = self.parts.take().expect("Use after finish");
|
||||||
let prefix = parts.prefix.trim().trim_right_matches('/');
|
let prefix = parts.prefix.trim().trim_right_matches('/');
|
||||||
@ -478,10 +491,10 @@ impl<S> App<S> where S: 'static {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience method for creating `Box<HttpHandler>` instance.
|
/// Convenience method for creating `Box<HttpHandler>` instances.
|
||||||
///
|
///
|
||||||
/// This method is useful if you need to register multiple application instances
|
/// This method is useful if you need to register multiple
|
||||||
/// with different state.
|
/// application instances with different state.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use std::thread;
|
/// # use std::thread;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
//! Actix web is a small, pragmatic, extremely fast, web framework for Rust.
|
//! Actix web is a small, pragmatic, and extremely fast web framework
|
||||||
|
//! for Rust.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use actix_web::{server, App, Path};
|
//! use actix_web::{server, App, Path};
|
||||||
@ -37,9 +38,9 @@
|
|||||||
//! * Configurable request routing
|
//! * Configurable request routing
|
||||||
//! * Graceful server shutdown
|
//! * Graceful server shutdown
|
||||||
//! * Multipart streams
|
//! * Multipart streams
|
||||||
//! * SSL support with openssl or native-tls
|
//! * SSL support with OpenSSL or `native-tls`
|
||||||
//! * Middlewares (`Logger`, `Session`, `CORS`, `CSRF`, `DefaultHeaders`)
|
//! * Middlewares (`Logger`, `Session`, `CORS`, `CSRF`, `DefaultHeaders`)
|
||||||
//! * Built on top of [Actix actor framework](https://github.com/actix/actix).
|
//! * Built on top of [Actix actor framework](https://github.com/actix/actix)
|
||||||
|
|
||||||
#![cfg_attr(actix_nightly, feature(
|
#![cfg_attr(actix_nightly, feature(
|
||||||
specialization, // for impl ErrorResponse for std::error::Error
|
specialization, // for impl ErrorResponse for std::error::Error
|
||||||
@ -189,7 +190,7 @@ pub mod dev {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod http {
|
pub mod http {
|
||||||
//! Various http related types
|
//! Various HTTP related types
|
||||||
|
|
||||||
// re-exports
|
// re-exports
|
||||||
pub use modhttp::{Method, StatusCode, Version};
|
pub use modhttp::{Method, StatusCode, Version};
|
||||||
|
Loading…
Reference in New Issue
Block a user