1
0
mirror of https://github.com/actix/actix-website synced 2024-11-30 19:14:36 +01:00

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

This commit is contained in:
Nikolay Kim 2018-05-24 09:33:56 -07:00
commit 2efb3dc0bd
2 changed files with 52 additions and 1 deletions

View File

@ -80,7 +80,7 @@ To create the key.pem and cert.pem use the command. **Fill in your own subject**
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem \ $ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem \
-days 365 -sha256 -subj "/C=CN/ST=Fujian/L=Xiamen/O=TVlinux/OU=Org/CN=muro.lxd" -days 365 -sha256 -subj "/C=CN/ST=Fujian/L=Xiamen/O=TVlinux/OU=Org/CN=muro.lxd"
``` ```
To remove the password, then copy nopass.pen to key.pem To remove the password, then copy nopass.pem to key.pem
```bash ```bash
$ openssl rsa -in key.pem -out nopass.pem $ openssl rsa -in key.pem -out nopass.pem
``` ```

View File

@ -285,6 +285,57 @@ foo/1/2/ -> Params{'bar':'1', 'tail': '2/'}
foo/abc/def/a/b/c -> Params{'bar':u'abc', 'tail': 'def/a/b/c'} foo/abc/def/a/b/c -> Params{'bar':u'abc', 'tail': 'def/a/b/c'}
``` ```
# Scoping Routes
Scoping helps you organize routes sharing common root paths. You can nest
scopes within scopes.
Suppose that you want to organize paths to endpoints used to manage a "Project",
consisting of "Tasks". Such paths may include:
- /project
- /project/{project_id}
- /project/{project_id}/task
- /project/{project_id}/task/{task_id}
A scoped layout of these paths would appear as follows
```rust
App::new()
.scope("/project", |proj_scope| {
proj_scope
.resource("", |r| {
r.method(Method::GET)
.f(get_projects);
r.method(Method::POST)
.f(create_project)})
.resource("/{project_id}", |r| {
r.method(Method::PUT)
.with(update_project);
r.method(Method::DELETE)
.f(delete_project)})
.nested("/{project_id}/task", |task_scope| {
task_scope
.resource("", |r| {
r.method(Method::GET)
.f(get_tasks);
r.method(Method::POST)
.f(create_task)})
.resource("/{task_id}", |r| {
r.method(Method::PUT)
.with(update_task);
r.method(Method::DELETE)
.with(delete_task)})})})
```
A *scoped* path can contain variable path segments as resources. Consistent with
unscoped paths, a scoped prefix without a trailing slash has one automatically
appended to it: `/app` converts to `/app/`.
You can get variable path segments from `HttpRequest::match_info()`.
`Path` extractor also is able to extract scope level variable segments.
# Match information # Match information
All values representing matched path segments are available in All values representing matched path segments are available in