Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(basics/router.md): [translate] Done #896

Merged
merged 7 commits into from May 17, 2017
Merged

Conversation

lslxdx
Copy link
Contributor

@lslxdx lslxdx commented May 11, 2017

Finish translating 'basics/router.md' and wait for guys to proofread it.

Checklist
  • documentation is changed or added
Affected core subsystem(s)
Description of change

Finish translating 'basics/router.md' and wait for guys to proofread it.
@codecov
Copy link

codecov bot commented May 11, 2017

Codecov Report

Merging #896 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #896   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          28     28           
  Lines         669    669           
=====================================
  Hits          669    669

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02b02e0...9fd042f. Read the comment docs.


Methods that are not needed may not be implemented in `posts.js` and the related URL paths will not be registered to Router neither.

## destroy in action
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept


## destroy in action

The destroy syntax will demonstrated by more examples.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面通过更多实际的例子,来说明 router 的用法。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept


> If you perform a POST request directly, an **error** will occur: 'secret is missing'. This error message comes from [koa-csrf/index.js#L69](https://github.com/koajs/csrf/blob/2.5.0/index.js#L69).

> **Reason**: the framework verifies the CSFR value specially for form POST requests, so please submit the CSRF key as well when you submit a form. For more detail refer to [Keep Away from CSRF Threat](https://eggjs.org/zh-cn/core/security.html#安全威胁csrf的防范)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

乱码了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LibreOffice的问题. 已改正.


```js
// app/router.js
module.exports = app => { require('./router/news')(app);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

换行

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

手误按了J, 已改正.


Router is mainly used to describe the relationship between the request URL and the Controller that processes the request eventually. All routing rules are unified in the `app/router.js` file by the framework.

By unifying routing rules, routing logics are free from scatter, random conflicts disappear and it becomes easy for us to see global routing rules.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'By unifying routing rules, routing logics are free from scatter, random conflicts disappear and ...'
It maybe more proper like this:
By unifying routing rules, routing logics are free from scatter that may cause unkown conflicts and it will be easier for us to check global routing rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct.

* app.patch - PATCH
* app.delete - DELETE
* app.del - this is a alias method due to the reservation of delete.
* app.redirect - redirect the request URL. For example, the most common case is to redirect the request accessing the root directory to the homepage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'app.redirect - redirect the request URL'
to redirect the request URL or redirecting the request the URL ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about 'redirects the request URL' which means 'app.redirect redirects the request URL'?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lslxdx Do you need update this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@popomore @Brian175 Yes, I've done.

* app.delete - DELETE
* app.del - this is a alias method due to the reservation of delete.
* app.redirect - redirect the request URL. For example, the most common case is to redirect the request accessing the root directory to the homepage.
- router-name define a alias for the route, and URL can be generated by helper method `pathFor` and `urlFor` provided by Helper. (Optional)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'define a alias for the route'
suggestion:
defines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

* app.redirect - redirect the request URL. For example, the most common case is to redirect the request accessing the root directory to the homepage.
- router-name define a alias for the route, and URL can be generated by helper method `pathFor` and `urlFor` provided by Helper. (Optional)
- path-match - URL path of the route.
- middleware1 - multiple Middlewares can be configured in Router. (Optional)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Middleware'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean 'multiple Middleware'?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've done.

- middleware1 - multiple Middlewares can be configured in Router. (Optional)
- controller.action - it's a string, take care. The framework will find the Controller sharing the name under `app/controller`, then assign the process to the configured action method. The action can be omitted if the Controller exports a method directly.

### IMPORTANT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Notices' may be more proper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct


> **Reason**: the framework verifies the CSFR value specially for form POST requests, so please submit the CSRF key as well when you submit a form. For more detail refer to [Keep Away from CSRF Threat](https://eggjs.org/zh-cn/core/security.html#安全威胁csrf的防范)

> **Note**: the verification is performed because the framework builds in a security plugin [egg-security](https://github.com/eggjs/egg-security) that provides some default security practices and this plugin is enabled by default. In case you want to disable some security protections, just configure the enable attribute of if to be false.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'just configure ...'
suggestion:
'just set the enable attribute to false'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept


> **Note**: the verification is performed because the framework builds in a security plugin [egg-security](https://github.com/eggjs/egg-security) that provides some default security practices and this plugin is enabled by default. In case you want to disable some security protections, just configure the enable attribute of if to be false.

> "Unless you know the consequence consciously, it's recommended not to disable functions provided by the security plugin"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‘unless ...’
suggestion: 'Unless you clearly confirm ..., it's not recommended ...'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept


### Using Middleware

A middleware can be used to change the request parameter of one kind of user requests to uppercase.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:
leave out 'of one kind of user requests'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

BTW, should we change the doc of Chinese version together?
e.g.:
'把用户某一类请求的参数都大写' => '把用户请求的参数都大写'

### Using Middleware

A middleware can be used to change the request parameter of one kind of user requests to uppercase.
Here we show how to use the middleware briefly, referring to [Middleware](./middleware.md) for detail.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:
'Here we just briefly explain how to use the middleware, refer to ...'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct.

Moreover, how about '..., and refer to ...'?


### Too Many Routing Maps?

As described above, we do not recommend you scatter routing logics all around, or it leads to a difficult trouble shooting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'we do not recommend ...'
suggestion:
'we do not recommend that ..., or it will bring trouble in trouble shooting'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct.

* app.patch - PATCH
* app.delete - DELETE
* app.del - this is a alias method due to the reservation of delete.
* app.redirect - redirect the request URL. For example, the most common case is to redirect the request accessing the root directory to the homepage.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lslxdx Do you need update this one?

@popomore popomore merged commit 25c7c95 into eggjs:master May 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants