From bc6bb9984f35847dac935ae2b809b213855daf3d Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 13 Jan 2018 11:17:48 -0800 Subject: [PATCH] user guide spelling --- CHANGES.md | 4 ++++ Cargo.toml | 9 +++++---- guide/src/qs_1.md | 2 +- guide/src/qs_10.md | 12 ++++++------ guide/src/qs_13.md | 2 +- guide/src/qs_14.md | 9 +++++---- guide/src/qs_3.md | 6 +++--- guide/src/qs_3_5.md | 2 +- guide/src/qs_4_5.md | 2 +- guide/src/qs_5.md | 30 +++++++++++++++--------------- guide/src/qs_7.md | 10 +++++----- guide/src/qs_9.md | 2 +- src/middleware/cors.rs | 5 ++--- 13 files changed, 50 insertions(+), 45 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index df1308f87..cfae08f82 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## 0.3.1 (2018-01-xx) + +* + ## 0.3.0 (2018-01-12) diff --git a/Cargo.toml b/Cargo.toml index 7cc567596..920c1e85d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-web" -version = "0.3.0" +version = "0.3.1" authors = ["Nikolay Kim "] description = "Actix web framework" readme = "README.md" @@ -11,7 +11,8 @@ documentation = "https://docs.rs/actix-web/" categories = ["network-programming", "asynchronous", "web-programming::http-server", "web-programming::websocket"] license = "MIT/Apache-2.0" -exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"] +exclude = [".gitignore", ".travis.yml", ".cargo/config", + "appveyor.yml", "examples/static"] build = "build.rs" [badges] @@ -55,10 +56,10 @@ smallvec = "0.6" bitflags = "1.0" num_cpus = "1.0" flate2 = "1.0" -cookie = { version="0.10", features=["percent-encode", "secure"] } # ring nightly compilation bug -# cookie = { git="https://github.com/alexcrichton/cookie-rs.git", features=["percent-encode", "secure"] } +# cookie = { version="0.10", features=["percent-encode", "secure"] } +cookie = { git="https://github.com/alexcrichton/cookie-rs.git", features=["percent-encode", "secure"] } # io mio = "0.6" diff --git a/guide/src/qs_1.md b/guide/src/qs_1.md index 8d2ee83c2..c9fbc8f35 100644 --- a/guide/src/qs_1.md +++ b/guide/src/qs_1.md @@ -17,7 +17,7 @@ If you already have rustup installed, run this command to ensure you have the la rustup update ``` -Actix web framework requies rust version 1.20 and up. +Actix web framework requires rust version 1.20 and up. ## Running Examples diff --git a/guide/src/qs_10.md b/guide/src/qs_10.md index 8cf8be0d8..1334ecdbe 100644 --- a/guide/src/qs_10.md +++ b/guide/src/qs_10.md @@ -1,7 +1,7 @@ # Middlewares -Actix middlewares system allows to add additional behaviour to request/response processing. -Middleware can hook into incomnig request process and modify request or halt request +Actix middlewares system allows to add additional behavior to request/response processing. +Middleware can hook into incoming request process and modify request or halt request processing and return response early. Also it can hook into response processing. Typically middlewares involves in following actions: @@ -12,9 +12,9 @@ Typically middlewares involves in following actions: * Access external services (redis, logging, sessions) Middlewares are registered for each application and get executed in same order as -registraton order. In general, *middleware* is a type that implements +registration order. In general, *middleware* is a type that implements [*Middleware trait*](../actix_web/middlewares/trait.Middleware.html). Each method -in this trait has default implementation. Each method can return result immidietly +in this trait has default implementation. Each method can return result immediately or *future* object. Here is example of simple middleware that adds request and response headers: @@ -148,7 +148,7 @@ fn main() { ## User sessions Actix provides general solution for session management. -[*Session storage*](../actix_web/middleware/struct.SessionStorage.html) middleare can be +[*Session storage*](../actix_web/middleware/struct.SessionStorage.html) middleware can be use with different backend types to store session data in different backends. By default only cookie session backend is implemented. Other backend implementations could be added later. @@ -162,7 +162,7 @@ You need to pass a random value to the constructor of *CookieSessionBackend*. This is private key for cookie session. When this value is changed, all session data is lost. Note that whatever you write into your session is visible by the user (but not modifiable). -In general case, you cretate +In general case, you create [*Session storage*](../actix_web/middleware/struct.SessionStorage.html) middleware and initializes it with specific backend implementation, like *CookieSessionBackend*. To access session data diff --git a/guide/src/qs_13.md b/guide/src/qs_13.md index 193b2e109..c6db174b4 100644 --- a/guide/src/qs_13.md +++ b/guide/src/qs_13.md @@ -4,7 +4,7 @@ Actix web automatically upgrades connection to *HTTP/2.0* if possible. ## Negotiation -*HTTP/2.0* protocol over tls without prior knowlage requires +*HTTP/2.0* protocol over tls without prior knowledge requires [tls alpn](https://tools.ietf.org/html/rfc7301). At the moment only `rust-openssl` has support. Turn on `alpn` feature to enable `alpn` negotiation. With enable `alpn` feature `HttpServer` provides diff --git a/guide/src/qs_14.md b/guide/src/qs_14.md index 26fa4ecfb..f29ce5634 100644 --- a/guide/src/qs_14.md +++ b/guide/src/qs_14.md @@ -36,8 +36,9 @@ We can send `CreateUser` message to `DbExecutor` actor, and as result we get ```rust,ignore impl Handler for DbExecutor { + type Result = Result - fn handle(&mut self, msg: CreateUser, _: &mut Self::Context) -> Response + fn handle(&mut self, msg: CreateUser, _: &mut Self::Context) -> Self::Result { use self::schema::users::dsl::*; @@ -59,7 +60,7 @@ impl Handler for DbExecutor { .load::(&self.0) .expect("Error loading person"); - Self::reply(items.pop().unwrap()) + Ok(items.pop().unwrap()) } } ``` @@ -77,7 +78,7 @@ struct State { fn main() { let sys = actix::System::new("diesel-example"); - // Start 3 parallele db executors + // Start 3 parallel db executors let addr = SyncArbiter::start(3, || { DbExecutor(SqliteConnection::establish("test.db").unwrap()) }); @@ -94,7 +95,7 @@ fn main() { } ``` -And finally we can use address in a requst handler. We get message response +And finally we can use address in a request handler. We get message response asynchronously, so handler needs to return future object, also `Route::a()` needs to be used for async handler registration. diff --git a/guide/src/qs_3.md b/guide/src/qs_3.md index c970b3efe..7a90c3b5d 100644 --- a/guide/src/qs_3.md +++ b/guide/src/qs_3.md @@ -2,7 +2,7 @@ Actix web provides some primitives to build web servers and applications with Rust. It provides routing, middlewares, pre-processing of requests, and post-processing of responses, -websocket protcol handling, multipart streams, etc. +websocket protocol handling, multipart streams, etc. All actix web server is built around `Application` instance. It is used for registering routes for resources, middlewares. @@ -10,9 +10,9 @@ Also it stores application specific state that is shared across all handlers within same application. Application acts as namespace for all routes, i.e all routes for specific application -has same url path prefix. Application prefix always contains laading "/" slash. +has same url path prefix. Application prefix always contains leading "/" slash. If supplied prefix does not contain leading slash, it get inserted. -Prefix should consists of valud path segments. i.e for application with prefix `/app` +Prefix should consists of value 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. diff --git a/guide/src/qs_3_5.md b/guide/src/qs_3_5.md index 977c1da8d..7982cd272 100644 --- a/guide/src/qs_3_5.md +++ b/guide/src/qs_3_5.md @@ -2,7 +2,7 @@ [*HttpServer*](../actix_web/struct.HttpServer.html) type is responsible for serving http requests. *HttpServer* accept application factory as a parameter, -Application factory must have `Send` + `Sync` bounderies. More about that in +Application factory must have `Send` + `Sync` boundaries. More about that in *multi-threading* section. To bind to specific socket address `bind()` must be used. This method could be called multiple times. To start http server one of the *start* methods could be used. `start()` method start simple server, `start_tls()` or `start_ssl()` diff --git a/guide/src/qs_4_5.md b/guide/src/qs_4_5.md index ef3a982ae..dcdea3fe5 100644 --- a/guide/src/qs_4_5.md +++ b/guide/src/qs_4_5.md @@ -5,7 +5,7 @@ and [`ResponseError` trait](../actix_web/error/trait.ResponseError.html) for handling handler's errors. Any error that implements `ResponseError` trait can be returned as error value. *Handler* can return *Result* object, actix by default provides -`Responder` implemenation for compatible result object. Here is implementation +`Responder` implementation for compatible result object. Here is implementation definition: ```rust,ignore diff --git a/guide/src/qs_5.md b/guide/src/qs_5.md index 1aa7edeb0..1589245a2 100644 --- a/guide/src/qs_5.md +++ b/guide/src/qs_5.md @@ -2,15 +2,15 @@ URL dispatch provides a simple way to map URLs to `Handler` code using a simple pattern matching language. *Regex* crate and it's -[*RegexSet*](https://doc.rust-lang.org/regex/regex/struct.RegexSet.html) is beeing used for +[*RegexSet*](https://doc.rust-lang.org/regex/regex/struct.RegexSet.html) is being used for pattern matching. If one of the patterns matches the path information associated with a request, a particular handler object is invoked. A handler is a specific object that implements `Handler` trait, defined in your application, that receives the request and returns -a response object. More informatin is available in [handler section](../qs_4.html). +a response object. More information is available in [handler section](../qs_4.html). ## Resource configuration -Resource configuraiton is the act of adding a new resource to an application. +Resource configuration is the act of adding a new resource to an application. A resource has a name, which acts as an identifier to be used for URL generation. The name also allows developers to add routes to existing resources. A resource also has a pattern, meant to match against the *PATH* portion of a *URL*, @@ -19,7 +19,7 @@ port, e.g., */foo/bar* in the *URL* *http://localhost:8080/foo/bar?q=value*). The [Application::resource](../actix_web/struct.Application.html#method.resource) methods add a single resource to application routing table. This method accepts *path pattern* -and resource configuration funnction. +and resource configuration function. ```rust # extern crate actix_web; @@ -39,20 +39,20 @@ fn main() { } ``` -*Configuraiton function* has following type: +*Configuration function* has following type: ```rust,ignore FnOnce(&mut Resource<_>) -> () ``` -*Configration function* can set name and register specific routes. +*Configuration function* can set name and register specific routes. If resource does not contain any route or does not have any matching routes it returns *NOT FOUND* http resources. ## Configuring a Route Resource contains set of routes. Each route in turn has set of predicates and handler. -New route could be crearted with `Resource::route()` method which returns reference +New route could be created with `Resource::route()` method which returns reference to new *Route* instance. By default *route* does not contain any predicates, so matches all requests and default handler is `HTTPNotFound`. @@ -91,17 +91,17 @@ builder-like pattern. Following configuration methods are available: any number of predicates could be registered for each route. * [*Route::f()*](../actix_web/struct.Route.html#method.f) method registers handler function - for this route. Only one handler could be registered. Usually handler registeration - is the last config operation. Handler fanction could be function or closure and has type + for this route. Only one handler could be registered. Usually handler registration + is the last config operation. Handler function could be function or closure and has type `Fn(HttpRequest) -> R + 'static` * [*Route::h()*](../actix_web/struct.Route.html#method.h) method registers handler object that implements `Handler` trait. This is similar to `f()` method, only one handler could - be registered. Handler registeration is the last config operation. + be registered. Handler registration is the last config operation. -* [*Route::a()*](../actix_web/struct.Route.html#method.a) method registers asynchandler - function for this route. Only one handler could be registered. Handler registeration - is the last config operation. Handler fanction could be function or closure and has type +* [*Route::a()*](../actix_web/struct.Route.html#method.a) method registers async handler + function for this route. Only one handler could be registered. Handler registration + is the last config operation. Handler function could be function or closure and has type `Fn(HttpRequest) -> Future + 'static` ## Route matching @@ -112,7 +112,7 @@ against a URL path pattern. `path` represents the path portion of the URL that w The way that *actix* does this is very simple. When a request enters the system, for each resource configuration registration present in the system, actix checks the request's path against the pattern declared. *Regex* crate and it's -[*RegexSet*](https://doc.rust-lang.org/regex/regex/struct.RegexSet.html) is beeing used for +[*RegexSet*](https://doc.rust-lang.org/regex/regex/struct.RegexSet.html) is being used for pattern matching. If resource could not be found, *default resource* get used as matched resource. @@ -516,7 +516,7 @@ Predicates can have access to application's state via `HttpRequest::state()` met Also predicates can store extra information in [requests`s extensions](../actix_web/struct.HttpRequest.html#method.extensions). -### Modifing predicate values +### Modifying predicate values You can invert the meaning of any predicate value by wrapping it in a `Not` predicate. For example if you want to return "METHOD NOT ALLOWED" response for all methods diff --git a/guide/src/qs_7.md b/guide/src/qs_7.md index 7cce5932b..3a96529a0 100644 --- a/guide/src/qs_7.md +++ b/guide/src/qs_7.md @@ -4,7 +4,7 @@ Builder-like patter is used to construct an instance of `HttpResponse`. `HttpResponse` provides several method that returns `HttpResponseBuilder` instance, -which is implements various convinience methods that helps build response. +which is implements various convenience methods that helps build response. Check [documentation](../actix_web/dev/struct.HttpResponseBuilder.html) for type description. Methods `.body`, `.finish`, `.json` finalizes response creation and returns constructed *HttpResponse* instance. if this methods get called for the same @@ -91,7 +91,7 @@ fn index(mut req: HttpRequest) -> Box> { # fn main() {} ``` -Or you can manually load payload into memory and ther deserialize it. +Or you can manually load payload into memory and then deserialize it. Here is simple example. We will deserialize *MyObj* struct. We need to load request body first and then deserialize json into object. @@ -200,7 +200,7 @@ fn index(req: HttpRequest) -> Box> { match item { // Handle multipart Field multipart::MultipartItem::Field(field) => { - println!("==== FIELD ==== {:?} {:?}", field.heders(), field.content_type()); + println!("==== FIELD ==== {:?} {:?}", field.headers(), field.content_type()); Either::A( // Field in turn is a stream of *Bytes* objects @@ -259,7 +259,7 @@ fn index(mut req: HttpRequest) -> Box> { Actix uses [*Payload*](../actix_web/payload/struct.Payload.html) object as request payload stream. *HttpRequest* provides several methods, which can be used for payload access. At the same time *Payload* implements *Stream* trait, so it could be used with various -stream combinators. Also *Payload* provides serveral convinience methods that return +stream combinators. Also *Payload* provides several convenience methods that return future object that resolve to Bytes object. * *readany()* method returns *Stream* of *Bytes* objects. @@ -283,7 +283,7 @@ use futures::{Future, Stream}; fn index(mut req: HttpRequest) -> Box> { - req.payload_mut() + req.payload() .readany() .from_err() .fold((), |_, chunk| { diff --git a/guide/src/qs_9.md b/guide/src/qs_9.md index 1b612a163..32fe7d3b6 100644 --- a/guide/src/qs_9.md +++ b/guide/src/qs_9.md @@ -3,7 +3,7 @@ Actix supports WebSockets out-of-the-box. It is possible to convert request's `Payload` to a stream of [*ws::Message*](../actix_web/ws/enum.Message.html) with a [*ws::WsStream*](../actix_web/ws/struct.WsStream.html) and then use stream -combinators to handle actual messages. But it is simplier to handle websocket communications +combinators to handle actual messages. But it is simpler to handle websocket communications with http actor. This is example of simple websocket echo server: diff --git a/src/middleware/cors.rs b/src/middleware/cors.rs index b04c81bbc..5c55c188c 100644 --- a/src/middleware/cors.rs +++ b/src/middleware/cors.rs @@ -100,7 +100,7 @@ pub enum CorsBuilderError { ParseError(http::Error), /// Credentials are allowed, but the Origin is set to "*". This is not allowed by W3C /// - /// This is a misconfiguration. Check the docuemntation for `Cors`. + /// This is a misconfiguration. Check the documentation for `Cors`. #[fail(display="Credentials are allowed, but the Origin is set to \"*\"")] CredentialsWithWildcardOrigin, } @@ -536,7 +536,7 @@ impl CorsBuilder { } /// Set a list of headers which are safe to expose to the API of a CORS API specification. - /// This corresponds to the `Access-Control-Expose-Headers` responde header. + /// This corresponds to the `Access-Control-Expose-Headers` response header. /// /// This is the `list of exposed headers` in the /// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model). @@ -584,7 +584,6 @@ impl CorsBuilder { /// in an `Error::CredentialsWithWildcardOrigin` error during actix launch or runtime. /// /// Defaults to `false`. - #[cfg_attr(feature = "serialization", serde(default))] pub fn send_wildcard(&mut self) -> &mut CorsBuilder { if let Some(cors) = cors(&mut self.cors, &self.error) { cors.send_wildcard = true