mirror of
https://github.com/fafhrd91/actix-web
synced 2024-12-18 01:43:58 +01:00
user guide spelling
This commit is contained in:
parent
c043fd7912
commit
bc6bb9984f
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## 0.3.1 (2018-01-xx)
|
||||||
|
|
||||||
|
*
|
||||||
|
|
||||||
|
|
||||||
## 0.3.0 (2018-01-12)
|
## 0.3.0 (2018-01-12)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-web"
|
name = "actix-web"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix web framework"
|
description = "Actix web framework"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@ -11,7 +11,8 @@ documentation = "https://docs.rs/actix-web/"
|
|||||||
categories = ["network-programming", "asynchronous",
|
categories = ["network-programming", "asynchronous",
|
||||||
"web-programming::http-server", "web-programming::websocket"]
|
"web-programming::http-server", "web-programming::websocket"]
|
||||||
license = "MIT/Apache-2.0"
|
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"
|
build = "build.rs"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
@ -55,10 +56,10 @@ smallvec = "0.6"
|
|||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
num_cpus = "1.0"
|
num_cpus = "1.0"
|
||||||
flate2 = "1.0"
|
flate2 = "1.0"
|
||||||
cookie = { version="0.10", features=["percent-encode", "secure"] }
|
|
||||||
|
|
||||||
# ring nightly compilation bug
|
# 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
|
# io
|
||||||
mio = "0.6"
|
mio = "0.6"
|
||||||
|
@ -17,7 +17,7 @@ If you already have rustup installed, run this command to ensure you have the la
|
|||||||
rustup update
|
rustup update
|
||||||
```
|
```
|
||||||
|
|
||||||
Actix web framework requies rust version 1.20 and up.
|
Actix web framework requires rust version 1.20 and up.
|
||||||
|
|
||||||
## Running Examples
|
## Running Examples
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Middlewares
|
# Middlewares
|
||||||
|
|
||||||
Actix middlewares system allows to add additional behaviour to request/response processing.
|
Actix middlewares system allows to add additional behavior to request/response processing.
|
||||||
Middleware can hook into incomnig request process and modify request or halt request
|
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.
|
processing and return response early. Also it can hook into response processing.
|
||||||
|
|
||||||
Typically middlewares involves in following actions:
|
Typically middlewares involves in following actions:
|
||||||
@ -12,9 +12,9 @@ Typically middlewares involves in following actions:
|
|||||||
* Access external services (redis, logging, sessions)
|
* Access external services (redis, logging, sessions)
|
||||||
|
|
||||||
Middlewares are registered for each application and get executed in same order as
|
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
|
[*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.
|
or *future* object.
|
||||||
|
|
||||||
Here is example of simple middleware that adds request and response headers:
|
Here is example of simple middleware that adds request and response headers:
|
||||||
@ -148,7 +148,7 @@ fn main() {
|
|||||||
## User sessions
|
## User sessions
|
||||||
|
|
||||||
Actix provides general solution for session management.
|
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.
|
use with different backend types to store session data in different backends.
|
||||||
By default only cookie session backend is implemented. Other backend implementations
|
By default only cookie session backend is implemented. Other backend implementations
|
||||||
could be added later.
|
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.
|
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).
|
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
|
[*Session storage*](../actix_web/middleware/struct.SessionStorage.html) middleware
|
||||||
and initializes it with specific backend implementation, like *CookieSessionBackend*.
|
and initializes it with specific backend implementation, like *CookieSessionBackend*.
|
||||||
To access session data
|
To access session data
|
||||||
|
@ -4,7 +4,7 @@ Actix web automatically upgrades connection to *HTTP/2.0* if possible.
|
|||||||
|
|
||||||
## Negotiation
|
## 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
|
[tls alpn](https://tools.ietf.org/html/rfc7301). At the moment only
|
||||||
`rust-openssl` has support. Turn on `alpn` feature to enable `alpn` negotiation.
|
`rust-openssl` has support. Turn on `alpn` feature to enable `alpn` negotiation.
|
||||||
With enable `alpn` feature `HttpServer` provides
|
With enable `alpn` feature `HttpServer` provides
|
||||||
|
@ -36,8 +36,9 @@ We can send `CreateUser` message to `DbExecutor` actor, and as result we get
|
|||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
impl Handler<CreateUser> for DbExecutor {
|
impl Handler<CreateUser> for DbExecutor {
|
||||||
|
type Result = Result<User, Error>
|
||||||
|
|
||||||
fn handle(&mut self, msg: CreateUser, _: &mut Self::Context) -> Response<Self, CreateUser>
|
fn handle(&mut self, msg: CreateUser, _: &mut Self::Context) -> Self::Result
|
||||||
{
|
{
|
||||||
use self::schema::users::dsl::*;
|
use self::schema::users::dsl::*;
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ impl Handler<CreateUser> for DbExecutor {
|
|||||||
.load::<models::User>(&self.0)
|
.load::<models::User>(&self.0)
|
||||||
.expect("Error loading person");
|
.expect("Error loading person");
|
||||||
|
|
||||||
Self::reply(items.pop().unwrap())
|
Ok(items.pop().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -77,7 +78,7 @@ struct State {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let sys = actix::System::new("diesel-example");
|
let sys = actix::System::new("diesel-example");
|
||||||
|
|
||||||
// Start 3 parallele db executors
|
// Start 3 parallel db executors
|
||||||
let addr = SyncArbiter::start(3, || {
|
let addr = SyncArbiter::start(3, || {
|
||||||
DbExecutor(SqliteConnection::establish("test.db").unwrap())
|
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
|
asynchronously, so handler needs to return future object, also `Route::a()` needs to be
|
||||||
used for async handler registration.
|
used for async handler registration.
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Actix web provides some primitives to build web servers and applications with Rust.
|
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,
|
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.
|
All actix web server is built around `Application` instance.
|
||||||
It is used for registering routes for resources, middlewares.
|
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.
|
within same application.
|
||||||
|
|
||||||
Application acts as namespace for all routes, i.e all routes for specific 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.
|
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,
|
any request with following paths `/app`, `/app/` or `/app/test` would match,
|
||||||
but path `/application` would not match.
|
but path `/application` would not match.
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[*HttpServer*](../actix_web/struct.HttpServer.html) type is responsible for
|
[*HttpServer*](../actix_web/struct.HttpServer.html) type is responsible for
|
||||||
serving http requests. *HttpServer* accept application factory as a parameter,
|
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.
|
*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*
|
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()`
|
methods could be used. `start()` method start simple server, `start_tls()` or `start_ssl()`
|
||||||
|
@ -5,7 +5,7 @@ and [`ResponseError` trait](../actix_web/error/trait.ResponseError.html)
|
|||||||
for handling handler's errors.
|
for handling handler's errors.
|
||||||
Any error that implements `ResponseError` trait can be returned as error value.
|
Any error that implements `ResponseError` trait can be returned as error value.
|
||||||
*Handler* can return *Result* object, actix by default provides
|
*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:
|
definition:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
URL dispatch provides a simple way to map URLs to `Handler` code using a simple pattern matching
|
URL dispatch provides a simple way to map URLs to `Handler` code using a simple pattern matching
|
||||||
language. *Regex* crate and it's
|
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,
|
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
|
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
|
`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 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.
|
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.
|
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*,
|
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
|
The [Application::resource](../actix_web/struct.Application.html#method.resource) methods
|
||||||
add a single resource to application routing table. This method accepts *path pattern*
|
add a single resource to application routing table. This method accepts *path pattern*
|
||||||
and resource configuration funnction.
|
and resource configuration function.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
# extern crate actix_web;
|
# extern crate actix_web;
|
||||||
@ -39,20 +39,20 @@ fn main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
*Configuraiton function* has following type:
|
*Configuration function* has following type:
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
FnOnce(&mut Resource<_>) -> ()
|
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
|
If resource does not contain any route or does not have any matching routes it
|
||||||
returns *NOT FOUND* http resources.
|
returns *NOT FOUND* http resources.
|
||||||
|
|
||||||
## Configuring a Route
|
## Configuring a Route
|
||||||
|
|
||||||
Resource contains set of routes. Each route in turn has set of predicates and handler.
|
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
|
to new *Route* instance. By default *route* does not contain any predicates, so matches
|
||||||
all requests and default handler is `HTTPNotFound`.
|
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.
|
any number of predicates could be registered for each route.
|
||||||
|
|
||||||
* [*Route::f()*](../actix_web/struct.Route.html#method.f) method registers handler function
|
* [*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
|
for this route. Only one handler could be registered. Usually handler registration
|
||||||
is the last config operation. Handler fanction could be function or closure and has type
|
is the last config operation. Handler function could be function or closure and has type
|
||||||
`Fn(HttpRequest<S>) -> R + 'static`
|
`Fn(HttpRequest<S>) -> R + 'static`
|
||||||
|
|
||||||
* [*Route::h()*](../actix_web/struct.Route.html#method.h) method registers handler object
|
* [*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
|
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 async handler
|
* [*Route::a()*](../actix_web/struct.Route.html#method.a) method registers async handler
|
||||||
function for this route. Only one handler could be registered. Handler registeration
|
function for this route. Only one handler could be registered. Handler registration
|
||||||
is the last config operation. Handler fanction could be function or closure and has type
|
is the last config operation. Handler function could be function or closure and has type
|
||||||
`Fn(HttpRequest<S>) -> Future<Item = HttpResponse, Error = Error> + 'static`
|
`Fn(HttpRequest<S>) -> Future<Item = HttpResponse, Error = Error> + 'static`
|
||||||
|
|
||||||
## Route matching
|
## 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,
|
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
|
for each resource configuration registration present in the system, actix checks
|
||||||
the request's path against the pattern declared. *Regex* crate and it's
|
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
|
pattern matching. If resource could not be found, *default resource* get used as matched
|
||||||
resource.
|
resource.
|
||||||
|
|
||||||
@ -516,7 +516,7 @@ Predicates can have access to application's state via `HttpRequest::state()` met
|
|||||||
Also predicates can store extra information in
|
Also predicates can store extra information in
|
||||||
[requests`s extensions](../actix_web/struct.HttpRequest.html#method.extensions).
|
[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.
|
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
|
For example if you want to return "METHOD NOT ALLOWED" response for all methods
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Builder-like patter is used to construct an instance of `HttpResponse`.
|
Builder-like patter is used to construct an instance of `HttpResponse`.
|
||||||
`HttpResponse` provides several method that returns `HttpResponseBuilder` instance,
|
`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)
|
Check [documentation](../actix_web/dev/struct.HttpResponseBuilder.html)
|
||||||
for type description. Methods `.body`, `.finish`, `.json` finalizes response creation and
|
for type description. Methods `.body`, `.finish`, `.json` finalizes response creation and
|
||||||
returns constructed *HttpResponse* instance. if this methods get called for the same
|
returns constructed *HttpResponse* instance. if this methods get called for the same
|
||||||
@ -91,7 +91,7 @@ fn index(mut req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
|
|||||||
# fn main() {}
|
# 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
|
Here is simple example. We will deserialize *MyObj* struct. We need to load request
|
||||||
body first and then deserialize json into object.
|
body first and then deserialize json into object.
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ fn index(req: HttpRequest) -> Box<Future<...>> {
|
|||||||
match item {
|
match item {
|
||||||
// Handle multipart Field
|
// Handle multipart Field
|
||||||
multipart::MultipartItem::Field(field) => {
|
multipart::MultipartItem::Field(field) => {
|
||||||
println!("==== FIELD ==== {:?} {:?}", field.heders(), field.content_type());
|
println!("==== FIELD ==== {:?} {:?}", field.headers(), field.content_type());
|
||||||
|
|
||||||
Either::A(
|
Either::A(
|
||||||
// Field in turn is a stream of *Bytes* objects
|
// Field in turn is a stream of *Bytes* objects
|
||||||
@ -259,7 +259,7 @@ fn index(mut req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
|
|||||||
Actix uses [*Payload*](../actix_web/payload/struct.Payload.html) object as request payload stream.
|
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.
|
*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
|
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.
|
future object that resolve to Bytes object.
|
||||||
|
|
||||||
* *readany()* method returns *Stream* of *Bytes* objects.
|
* *readany()* method returns *Stream* of *Bytes* objects.
|
||||||
@ -283,7 +283,7 @@ use futures::{Future, Stream};
|
|||||||
|
|
||||||
|
|
||||||
fn index(mut req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
|
fn index(mut req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
|
||||||
req.payload_mut()
|
req.payload()
|
||||||
.readany()
|
.readany()
|
||||||
.from_err()
|
.from_err()
|
||||||
.fold((), |_, chunk| {
|
.fold((), |_, chunk| {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
Actix supports WebSockets out-of-the-box. It is possible to convert request's `Payload`
|
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
|
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
|
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.
|
with http actor.
|
||||||
|
|
||||||
This is example of simple websocket echo server:
|
This is example of simple websocket echo server:
|
||||||
|
@ -100,7 +100,7 @@ pub enum CorsBuilderError {
|
|||||||
ParseError(http::Error),
|
ParseError(http::Error),
|
||||||
/// Credentials are allowed, but the Origin is set to "*". This is not allowed by W3C
|
/// 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 \"*\"")]
|
#[fail(display="Credentials are allowed, but the Origin is set to \"*\"")]
|
||||||
CredentialsWithWildcardOrigin,
|
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.
|
/// 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
|
/// This is the `list of exposed headers` in the
|
||||||
/// [Resource Processing Model](https://www.w3.org/TR/cors/#resource-processing-model).
|
/// [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.
|
/// in an `Error::CredentialsWithWildcardOrigin` error during actix launch or runtime.
|
||||||
///
|
///
|
||||||
/// Defaults to `false`.
|
/// Defaults to `false`.
|
||||||
#[cfg_attr(feature = "serialization", serde(default))]
|
|
||||||
pub fn send_wildcard(&mut self) -> &mut CorsBuilder {
|
pub fn send_wildcard(&mut self) -> &mut CorsBuilder {
|
||||||
if let Some(cors) = cors(&mut self.cors, &self.error) {
|
if let Some(cors) = cors(&mut self.cors, &self.error) {
|
||||||
cors.send_wildcard = true
|
cors.send_wildcard = true
|
||||||
|
Loading…
Reference in New Issue
Block a user