1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 01:32:57 +01:00

Merge branch 'master' of github.com:actix/actix-web

This commit is contained in:
Nikolay Kim 2018-01-20 16:12:51 -08:00
commit 867bb1d409
21 changed files with 44 additions and 44 deletions

View File

@ -8,7 +8,7 @@ use diesel::prelude::*;
use models;
use schema;
/// This is db executor actor. We are going to run 3 of them in parallele.
/// This is db executor actor. We are going to run 3 of them in parallel.
pub struct DbExecutor(pub SqliteConnection);
/// This is only message that this actor can handle, but it is easy to extend number of

View File

@ -1,5 +1,5 @@
#![cfg_attr(feature="cargo-clippy", allow(needless_pass_by_value))]
//! There are two level of statfulness in actix-web. Application has state
//! There are two level of statefulness in actix-web. Application has state
//! that is shared across all handlers within same Application.
//! And individual handler can have state.

View File

@ -9,7 +9,7 @@ use std::io::Read;
use actix_web::*;
/// somple handle
/// simple handle
fn index(req: HttpRequest) -> Result<HttpResponse> {
println!("{:?}", req);
Ok(httpcodes::HTTPOk

View File

@ -16,8 +16,8 @@ Chat server listens for incoming tcp connections. Server can access several type
* `\list` - list all available rooms
* `\join name` - join room, if room does not exist, create new one
* `\name name` - set session name
* `some message` - just string, send messsage to all peers in same room
* client has to send heartbeat `Ping` messages, if server does not receive a heartbeat message for 10 seconds connection gets droppped
* `some message` - just string, send message to all peers in same room
* client has to send heartbeat `Ping` messages, if server does not receive a heartbeat message for 10 seconds connection gets dropped
To start server use command: `cargo run --bin server`

View File

@ -16,7 +16,7 @@ use codec::{ChatRequest, ChatResponse, ChatCodec};
#[derive(Message)]
pub struct Message(pub String);
/// `ChatSession` actor is responsible for tcp peer communitions.
/// `ChatSession` actor is responsible for tcp peer communications.
pub struct ChatSession {
/// unique session id
id: usize,
@ -30,7 +30,7 @@ pub struct ChatSession {
impl Actor for ChatSession {
/// For tcp communication we are going to use `FramedContext`.
/// It is convinient wrapper around `Framed` object from `tokio_io`
/// It is convenient wrapper around `Framed` object from `tokio_io`
type Context = FramedContext<Self>;
fn started(&mut self, ctx: &mut Self::Context) {
@ -149,7 +149,7 @@ impl ChatSession {
}
/// Define tcp server that will accept incomint tcp connection and create
/// Define tcp server that will accept incoming tcp connection and create
/// chat actors.
pub struct TcpServer {
chat: SyncAddress<ChatServer>,

View File

@ -136,7 +136,7 @@ impl<S> Application<S> where S: 'static {
/// Create application with specific state. Application can be
/// configured with builder-like pattern.
///
/// State is shared with all reousrces within same application and could be
/// State is shared with all resources within same application and could be
/// accessed with `HttpRequest::state()` method.
pub fn with_state(state: S) -> Application<S> {
Application {
@ -156,7 +156,7 @@ impl<S> Application<S> where S: 'static {
/// Set application prefix
///
/// Only requests that matches application's prefix get processed by this application.
/// Application prefix always contains laading "/" slash. If supplied prefix
/// Application prefix always contains leading "/" slash. If supplied prefix
/// 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`

View File

@ -31,7 +31,7 @@ pub enum Binary {
Bytes(Bytes),
/// Static slice
Slice(&'static [u8]),
/// Shared stirng body
/// Shared string body
SharedString(Rc<String>),
/// Shared string body
#[doc(hidden)]

View File

@ -127,7 +127,7 @@ impl<A, S> HttpContext<A, S> where A: Actor<Context=Self> {
}
}
/// Indicate end of streamimng payload. Also this method calls `Self::close`.
/// Indicate end of streaming payload. Also this method calls `Self::close`.
#[inline]
pub fn write_eof(&mut self) {
self.add_frame(Frame::Chunk(None));

View File

@ -320,7 +320,7 @@ pub enum WsHandshakeError {
/// Only get method is allowed
#[fail(display="Method not allowed")]
GetMethodRequired,
/// Ugrade header if not set to websocket
/// Upgrade header if not set to websocket
#[fail(display="Websocket upgrade is expected")]
NoWebsocketUpgrade,
/// Connection header is not set to upgrade
@ -329,7 +329,7 @@ pub enum WsHandshakeError {
/// Websocket version header is not set
#[fail(display="Websocket version header is required")]
NoVersionHeader,
/// Unsupported websockt version
/// Unsupported websocket version
#[fail(display="Unsupported version")]
UnsupportedVersion,
/// Websocket key is not set or wrong
@ -510,7 +510,7 @@ macro_rules! ERROR_WRAP {
/// Helper type that can wrap any error and generate *BAD REQUEST* response.
///
/// In following example any `io::Error` will be converted into "BAD REQUEST" response
/// as oposite to *INNTERNAL SERVER ERROR* which is defined by default.
/// as opposite to *INNTERNAL SERVER ERROR* which is defined by default.
///
/// ```rust
/// # extern crate actix_web;

View File

@ -9,7 +9,7 @@ use error::Error;
use httprequest::HttpRequest;
use httpresponse::HttpResponse;
/// Trait defines object that could be regestered as route handler
/// Trait defines object that could be registered as route handler
#[allow(unused_variables)]
pub trait Handler<S>: 'static {
@ -35,7 +35,7 @@ pub trait Responder {
}
#[doc(hidden)]
/// Convinience trait that convert `Future` object into `Boxed` future
/// Convenience trait that convert `Future` object into `Boxed` future
pub trait AsyncResponder<I, E>: Sized {
fn responder(self) -> Box<Future<Item=I, Error=E>>;
}
@ -193,7 +193,7 @@ impl<I, E> Responder for Box<Future<Item=I, Error=E>>
}
}
/// Trait defines object that could be regestered as resource route
/// Trait defines object that could be registered as resource route
pub(crate) trait RouteHandler<S>: 'static {
fn handle(&mut self, req: HttpRequest<S>) -> Reply;
}
@ -341,7 +341,7 @@ impl Default for NormalizePath {
}
impl NormalizePath {
/// Create new `NoramlizePath` instance
/// Create new `NormalizePath` instance
pub fn new(append: bool, merge: bool, redirect: StatusCode) -> NormalizePath {
NormalizePath {
append: append,

View File

@ -222,7 +222,7 @@ impl<S> HttpRequest<S> {
self.uri().path()
}
/// Get *ConnectionInfo* for currect request.
/// Get *ConnectionInfo* for correct request.
pub fn connection_info(&self) -> &ConnectionInfo {
if self.as_ref().info.is_none() {
let info: ConnectionInfo<'static> = unsafe{
@ -278,7 +278,7 @@ impl<S> HttpRequest<S> {
/// Peer socket address
///
/// Peer address is actuall socket address, if proxy is used in front of
/// 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.
///
/// To get client connection information `connection_info()` method should be used.

View File

@ -214,7 +214,7 @@ impl Cors {
/// This method register cors middleware with resource and
/// adds route for *OPTIONS* preflight requests.
///
/// It is possible to register *Cors* middlware with `Resource::middleware()`
/// It is possible to register *Cors* middleware with `Resource::middleware()`
/// method, but in that case *Cors* middleware wont be able to handle *OPTIONS*
/// requests.
pub fn register<S: 'static>(self, resource: &mut Resource<S>) {

View File

@ -217,7 +217,7 @@ pub struct CookieSession {
inner: Rc<CookieSessionInner>,
}
/// Errors that can occure during handling cookie session
/// Errors that can occur during handling cookie session
#[derive(Fail, Debug)]
pub enum CookieSessionError {
/// Size of the serialized session is greater than 4000 bytes.

View File

@ -77,7 +77,7 @@ impl<'a> Params<'a> {
}
}
/// Return iterator to items in paramter container
/// Return iterator to items in parameter container
pub fn iter(&self) -> Iter<(Cow<'a, str>, Cow<'a, str>)> {
self.0.iter()
}

View File

@ -210,7 +210,7 @@ impl<S: 'static, H: PipelineHandler<S>> StartMiddlewares<S, H> {
fn init(info: &mut PipelineInfo<S>, handler: Rc<RefCell<H>>) -> PipelineState<S, H> {
// execute middlewares, we need this stage because middlewares could be non-async
// and we can move to next state immidietly
// and we can move to next state immediately
let len = info.mws.len();
loop {
if info.count == len {

View File

@ -19,7 +19,7 @@ use httpresponse::HttpResponse;
/// Route uses builder-like pattern for configuration.
/// During request handling, resource object iterate through all routes
/// and check all predicates for specific route, if request matches all predicates route
/// route considired matched and route handler get called.
/// route considered matched and route handler get called.
///
/// ```rust
/// # extern crate actix_web;

View File

@ -660,7 +660,7 @@ enum TransferEncodingKind {
Length(u64),
/// An Encoder for when Content-Length is not known.
///
/// Appliction decides when to stop writing.
/// Application decides when to stop writing.
Eof,
}

View File

@ -96,7 +96,7 @@ impl<T, H> Http1<T, H>
}
}
// TODO: refacrtor
// TODO: refactor
#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
pub fn poll(&mut self) -> Poll<(), ()> {
// keep-alive timer
@ -133,7 +133,7 @@ impl<T, H> Http1<T, H>
Ok(Async::Ready(ready)) => {
not_ready = false;
// overide keep-alive state
// override keep-alive state
if self.stream.keepalive() {
self.flags.insert(Flags::KEEPALIVE);
} else {
@ -1204,7 +1204,7 @@ mod tests {
let mut buf = Buffer::new(
"GET /test HTTP/1.1\r\n\
transfer-encoding: chnked\r\n\r\n");
transfer-encoding: chunked\r\n\r\n");
let req = parse_ready!(&mut buf);
if let Ok(val) = req.chunked() {

View File

@ -268,9 +268,9 @@ impl<H: HttpHandler, U, V> HttpServer<TcpStream, net::SocketAddr, H, U>
where U: IntoIterator<Item=V> + 'static,
V: IntoHttpHandler<Handler=H>,
{
/// Start listening for incomming connections.
/// Start listening for incoming connections.
///
/// This method starts number of http handler workers in seperate threads.
/// This method starts number of http handler workers in separate threads.
/// For each address this method starts separate thread which does `accept()` in a loop.
///
/// This methods panics if no socket addresses get bound.
@ -298,7 +298,7 @@ impl<H: HttpHandler, U, V> HttpServer<TcpStream, net::SocketAddr, H, U>
pub fn start(mut self) -> SyncAddress<Self>
{
if self.sockets.is_empty() {
panic!("HttpServer::bind() has to be called befor start()");
panic!("HttpServer::bind() has to be called before start()");
} else {
let addrs: Vec<(net::SocketAddr, net::TcpListener)> =
self.sockets.drain().collect();
@ -320,7 +320,7 @@ impl<H: HttpHandler, U, V> HttpServer<TcpStream, net::SocketAddr, H, U>
}
}
/// Spawn new thread and start listening for incomming connections.
/// Spawn new thread and start listening for incoming connections.
///
/// This method spawns new thread and starts new actix system. Other than that it is
/// similar to `start()` method. This method blocks.
@ -359,7 +359,7 @@ impl<H: HttpHandler, U, V> HttpServer<TlsStream<TcpStream>, net::SocketAddr, H,
where U: IntoIterator<Item=V> + 'static,
V: IntoHttpHandler<Handler=H>,
{
/// Start listening for incomming tls connections.
/// Start listening for incoming tls connections.
pub fn start_tls(mut self, pkcs12: ::Pkcs12) -> io::Result<SyncAddress<Self>> {
if self.sockets.is_empty() {
Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound"))
@ -398,7 +398,7 @@ impl<H: HttpHandler, U, V> HttpServer<SslStream<TcpStream>, net::SocketAddr, H,
where U: IntoIterator<Item=V> + 'static,
V: IntoHttpHandler<Handler=H>,
{
/// Start listening for incomming tls connections.
/// Start listening for incoming tls connections.
///
/// This method sets alpn protocols to "h2" and "http/1.1"
pub fn start_ssl(mut self, identity: &ParsedPkcs12) -> io::Result<SyncAddress<Self>> {
@ -443,7 +443,7 @@ impl<T, A, H, U, V> HttpServer<WrapperStream<T>, A, H, U>
U: IntoIterator<Item=V> + 'static,
V: IntoHttpHandler<Handler=H>,
{
/// Start listening for incomming connections from a stream.
/// Start listening for incoming connections from a stream.
///
/// This method uses only one thread for handling incoming connections.
pub fn start_incoming<S>(mut self, stream: S, secure: bool) -> SyncAddress<Self>
@ -663,7 +663,7 @@ fn start_accept_thread(sock: net::TcpListener, addr: net::SocketAddr, backlog: i
}
}
// Start listening for incommin commands
// Start listening for incoming commands
if let Err(err) = poll.register(&reg, CMD,
mio::Ready::readable(), mio::PollOpt::edge()) {
panic!("Can not register Registration: {}", err);

View File

@ -29,7 +29,7 @@ use server::{HttpServer, HttpHandler, IntoHttpHandler, ServerSettings};
/// The `TestServer` type.
///
/// `TestServer` is very simple test server that simplify process of writing
/// integrational tests cases for actix web applications.
/// integration tests cases for actix web applications.
///
/// # Examples
///
@ -61,7 +61,7 @@ impl TestServer {
/// Start new test server
///
/// This methos accepts configuration method. You can add
/// This method accepts configuration method. You can add
/// middlewares or set handlers for test application.
pub fn new<F>(config: F) -> Self
where F: Sync + Send + 'static + Fn(&mut TestApp<()>),
@ -101,7 +101,7 @@ impl TestServer {
/// Start new test server with custom application state
///
/// This methos accepts state factory and configuration method.
/// This method accepts state factory and configuration method.
pub fn with_state<S, FS, F>(state: FS, config: F) -> Self
where S: 'static,
FS: Sync + Send + 'static + Fn() -> S,
@ -287,12 +287,12 @@ impl Default for TestRequest<()> {
impl TestRequest<()> {
/// Create TestReqeust and set request uri
/// Create TestRequest and set request uri
pub fn with_uri(path: &str) -> TestRequest<()> {
TestRequest::default().uri(path)
}
/// Create TestReqeust and set header
/// Create TestRequest and set header
pub fn with_header<K, V>(key: K, value: V) -> TestRequest<()>
where HeaderName: HttpTryFrom<K>,
HeaderValue: HttpTryFrom<V>

View File

@ -28,7 +28,7 @@ pub(crate) struct Frame {
impl Frame {
/// Desctructe frame
/// Destruct frame
pub fn unpack(self) -> (bool, OpCode, Binary) {
(self.finished, self.opcode, self.payload)
}