Skip to content

Commit 223daf7

Browse files
authored
Merge pull request #4 from jamesfancy/master
translate developers and api.
2 parents 67f70ae + 6109ada commit 223daf7

File tree

6 files changed

+86
-98
lines changed

6 files changed

+86
-98
lines changed

source/api/index.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
title: Node.js API
22
---
33

4-
> 如果你愿意帮助hiproxy编写文档,请联系zdying@live.com, 谢谢!
5-
>
64
> If you are willing to help hiproxy to write documentation, please contact zdying@live.com, thank you!
75
86
<a name="ProxyServer"></a>
@@ -24,110 +22,110 @@ title: Node.js API
2422
<a name="new_ProxyServer_new"></a>
2523

2624
### new ProxyServer(httpPort, httpsPort)
27-
hiproxy代理服务器
25+
Hiproxy's proxy server.
2826

2927

3028
| Param | Type | Description |
3129
| --- | --- | --- |
32-
| httpPort | <code>Number</code> | http代理服务端口号 |
33-
| httpsPort | <code>Number</code> | https代理服务器端口号 |
30+
| httpPort | <code>Number</code> | proxy server port for http |
31+
| httpsPort | <code>Number</code> | proxy server port for https |
3432

3533
<a name="ProxyServer+start"></a>
3634

3735
### proxyServer.start([config]) ⇒ <code>Promise</code>
38-
启动代理服务
36+
Start proxy server.
3937

4038
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
4139
**Access**: public
4240

4341
| Param | Type | Description |
4442
| --- | --- | --- |
45-
| config | <code>Object</code> | 配置字段 |
43+
| config | <code>Object</code> | configuration fields |
4644

4745
<a name="ProxyServer+stop"></a>
4846

4947
### proxyServer.stop() ⇒ [<code>ProxyServer</code>](#ProxyServer)
50-
停止代理服务
48+
Stop proxy server.
5149

5250
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
5351
**Access**: public
5452
<a name="ProxyServer+restart"></a>
5553

5654
### proxyServer.restart() ⇒ [<code>ProxyServer</code>](#ProxyServer)
57-
重启代理服务
55+
Restart proxy server.
5856

5957
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
6058
**Access**: public
6159
<a name="ProxyServer+addHostsFile"></a>
6260

6361
### proxyServer.addHostsFile(filePath) ⇒ [<code>ProxyServer</code>](#ProxyServer)
64-
添加Hosts文件
62+
Add a *hosts* file.
6563

6664
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
6765
**Access**: public
6866

6967
| Param | Type | Description |
7068
| --- | --- | --- |
71-
| filePath | <code>String</code> \| <code>Array</code> | `hosts`文件路径(绝对路径) |
69+
| filePath | <code>String</code> \| <code>Array</code> | `hosts` file path(s) (absolute) |
7270

7371
<a name="ProxyServer+addRewriteFile"></a>
7472

7573
### proxyServer.addRewriteFile(filePath) ⇒ [<code>ProxyServer</code>](#ProxyServer)
76-
添加rewrite文件
74+
Add a *rewrite* file.
7775

7876
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
7977
**Access**: public
8078

8179
| Param | Type | Description |
8280
| --- | --- | --- |
83-
| filePath | <code>String</code> \| <code>Array</code> | `rewrite`文件路径(绝对路径) |
81+
| filePath | <code>String</code> \| <code>Array</code> | `rewrite` file path(s) (absolute) |
8482

8583
<a name="ProxyServer+openBrowser"></a>
8684

8785
### proxyServer.openBrowser(browserName, url, [usePacProxy]) ⇒ [<code>ProxyServer</code>](#ProxyServer)
88-
打开浏览器窗口
86+
Open a browser.
8987

9088
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
9189
**Access**: public
9290

9391
| Param | Type | Default | Description |
9492
| --- | --- | --- | --- |
95-
| browserName | <code>String</code> | | 浏览器名称 |
96-
| url | <code>String</code> | | 要打开的url |
97-
| [usePacProxy] | <code>Boolean</code> | <code>false</code> | 是否使用自动代理 |
93+
| browserName | <code>String</code> | | browser name |
94+
| url | <code>String</code> | | the URL should be opened |
95+
| [usePacProxy] | <code>Boolean</code> | <code>false</code> | whether use PAC proxy |
9896

9997
<a name="ProxyServer+findConfigFiels"></a>
10098

10199
### proxyServer.findConfigFiles([dir]) ⇒ [<code>ProxyServer</code>](#ProxyServer)
102-
在指定工作空间(目录)下查找配置文件
103-
hiproxy会在指定的空间下所有一级目录下查找配置文件
100+
Look for configuration files within the workspace (directory).
101+
Hiproxy looks for configuration files from immediate child directories of workspace.
104102

105103
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
106104
**Access**: public
107105

108106
| Param | Type | Default | Description |
109107
| --- | --- | --- | --- |
110-
| [dir] | <code>String</code> | <code>process.cwd()</code> | 工作空间(目录) |
108+
| [dir] | <code>String</code> | <code>process.cwd()</code> | workspace (directory) |
111109

112110

113111
### proxyServer.enableConfFile(confFileType, filePath) ⇒ [<code>ProxyServer</code>](#ProxyServer)
114-
启用指定配置文件
112+
Enable specified configuration file.
115113

116114
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
117115
**Access**: public
118116

119117
| Param | Type | Default | Description |
120118
| --- | --- | --- | --- |
121-
| confFileType | <code>String</code> | | 文件类型(host/rewrite) |
122-
| filePath | <code>String</code> \| <code>Array</code> | | 修改的文件路径 |
119+
| confFileType | <code>String</code> | | file type (host/rewrite) |
120+
| filePath | <code>String</code> \| <code>Array</code> | | modified file path(s) |
123121

124122
### proxyServer.disableConfFile(confFileType, filePath) ⇒ [<code>ProxyServer</code>](#ProxyServer)
125-
禁用指定配置文件
123+
Disable specified configuration file.
126124

127125
**Kind**: instance method of [<code>ProxyServer</code>](#ProxyServer)
128126
**Access**: public
129127

130128
| Param | Type | Default | Description |
131129
| --- | --- | --- | --- |
132-
| confFileType | <code>String</code> | | 文件类型(host/rewrite) |
133-
| filePath | <code>String</code> \| <code>Array</code> | | 修改的文件路径 |
130+
| confFileType | <code>String</code> | | file type (host/rewrite) |
131+
| filePath | <code>String</code> \| <code>Array</code> | | modified file path(s) |

source/developers/cli_command.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
title: CLI Command
2-
---
32

4-
> 如果你愿意帮助hiproxy编写文档,请联系zdying@live.com, 谢谢!
5-
>
63
> If you are willing to help hiproxy to write documentation, please contact zdying@live.com, thank you!
74
8-
## 简介
5+
## Introduction
96

10-
hiproxy的CLI提供了`start`/`stop`/`state`/`open`等命令,如果这些命令不能满足你的需求,也可以为hiproxy添加新的命令。
7+
CLI of hiproxy supplied commands such as `start`, `stop`, `state` and `open`. If then are not enought, you can add your own ones.
118

12-
新增的命令需要配置的内容为:`命令名称``描述``使用方法``处理函数``命令选项参数`。对应的字段为:
9+
You should define something, such as `command name`, `description`, `handler` and `options`, for the new command. This is description:
1310

14-
* **命令名称(command)**`<String>`,比如:`'hello'`
15-
* **描述信息(describe)**`<String>`,简单介绍命令的作用以及其他的信息,比如:`'A test command that say hello to you.'`
16-
* **使用方法(usage)**`<String>`,命令的使用方法提示信息,比如:`'hello [--name <name>] [-xodD]'`
17-
* **处理函数(fn)**`<Function>`,执行命令时,调用的函数。函数调用时`this`值为命令行参数解析后的对象。
18-
* **命令选项(option)**`<Object>`,命令对应的选项,`key:value`形式。可以参考<https://github.com/hemsl/hemsl>
11+
* **Command Name(command)**`<String>`, i.e. `'hello'`
12+
* **Description(describe)**`<String>`, summary about the command's usage or more, i.e. `'A test command that say hello to you.'`
13+
* **Usage(usage)**`<String>`, command usage, i.e. `'hello [--name <name>] [-xodD]'`
14+
* **Handler(fn)**`<Function>`, the command invokes the handler while it's executing. `this` of the handler refer to a object which describes command line arguments.
15+
* **Options(option)**`<Object>`, options for the command, supplied in form of `key:value`. See <https://github.com/hemsl/hemsl>.
1916

20-
## 示例
17+
## Example
2118

22-
一个完整的命令示例如下:
19+
A whole example of custom command is:
2320

2421
```js
2522
{

source/developers/directive.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
title: Rewrite Directive
22
---
33

4-
> 如果你愿意帮助hiproxy编写文档,请联系zdying@live.com, 谢谢!
5-
>
64
> If you are willing to help hiproxy to write documentation, please contact zdying@live.com, thank you!
75
8-
## 简介
6+
## Introduction
97

10-
**rewrite指令**可以配置的内容为:`指令名称``作用域``处理函数`。对应的字段为:
8+
**rewrite directive** can configure `directive name`, `scopes` and `handler`. They are:
119

12-
* **指令名称(name)**`<String>`,比如:`'add'`
13-
* **作用域(scope)**`<Array>`,指令对应的作用域,只有在这里指定的作用域里面才会执行。可选择的作用域为:`global``domain``location``request``response`
14-
* **处理函数(fn)**`<Function>`,执行指令时,调用的函数,详细信息请查看[处理函数](#handler-function)
10+
* **Directive Name(name)**`<String>`, i.e. `'add'`
11+
* **Scopes(scope)**`<Array>`, the scopes which the directive runs in. The directive is only valid in specified scopes. The scopes include `global`, `domain`, `location`, `request` and `response`.
12+
* **Handler(fn)**`<Function>`, the handler should be invoked while the directive is execute. See [handler](#handler-function) for details.
1513

16-
## 示例
14+
## Example
1715

18-
一个完整的指令示例如下:
16+
Here is a entire example of directive:
1917

2018
```js
2119
{
@@ -32,20 +30,20 @@ title: Rewrite Directive
3230

3331
<a name="handler-function"></a>
3432

35-
## 处理函数
33+
## Handler
3634

37-
处理函数会在hiproxy执行指令的时候被调用,传入rewrite配置文件中这个指令对应的参数,并设置`this`
35+
The handler is invoked while hiproxy is executing related directive. The parameters whick are specified for the directive in *rewrite* configuration are passed in and `this` should be setted.
3836

39-
### 参数
37+
### Parameters
4038

41-
处理函数会被调用是,会传入rewrite配置文件中这个指令对应的参数,例如配置了指令`proxy_set_header Host hiproxy.org`,那么在执行**处理函数**时,传入的参数为:`('Host', 'hiproxy.org')`
39+
The parameters for the directive in *rewrite* configuration should be passed into handler. For example, `proxy_set_header Host hiproxy.org` is configured then `('Host', 'hiproxy.org')` should be passed into **the handler**.
4240

4341
### this
4442

45-
不同作用域中的指令执行时,this值也不同,下面列举了所有作用域指令对应的this值:
43+
`this` value is depended on the scope which the directive executs in. Following are possible `this` values:
4644

47-
- **global**: 整个rewrite对象-`{props: <Object>, domains: <Array>, commands: <Array>}}`
48-
- **domain**: domain对象-`{domain: <String>, props: <Object>, location: <Array>, commands: <Array>}}`
49-
- **location**: location对象-`{props: <Object>, location: <String>, commands: <Array>}}`
45+
- **global**: the entire *rewrite* instance - `{props: <Object>, domains: <Array>, commands: <Array>}}`
46+
- **domain**: domain instance - `{domain: <String>, props: <Object>, location: <Array>, commands: <Array>}}`
47+
- **location**: location instance - `{props: <Object>, location: <String>, commands: <Array>}}`
5048
- **request**: `{request: <http.IncomingMessage>}`
5149
- **response**: `{response: <http.ServerResponse>}`

source/developers/index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
title: hiproxy开发者指南
1+
title: Hiproxy Develpment Guide
22
---
33

4-
> 如果你愿意帮助hiproxy编写文档,请联系zdying@live.com, 谢谢!
5-
>
64
> If you are willing to help hiproxy to write documentation, please contact zdying@live.com, thank you!

source/developers/plugin.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
title: Plugin 插件开发指南
1+
title: Plugin Development Guide
22
---
33

4-
hiproxy提供了一套插件开发机制,这个机制很简单:插件开发完成后,将插件安装到全局,hiproxy启动时会自动查找安装的所有插件。
4+
Hiproxy supplied a mechanism of developing plugins. It's simple that you need just develop a plugin and install it to global. Hiproxy should look for and load all plugins while it starts.
55

6-
开发者开发新插件时,可以参考`hiproxy-plugin-example`: <https://github.com/hiproxy/hiproxy-plugin-example>。这是一个完整的插件示例,你可以基于这个示例修改。
6+
If you want to develop a plugin, `hiproxy-plugin-example` is a good demo which you can find at <https://github.com/hiproxy/hiproxy-plugin-example>. This is a entire plugin demo, you can start your own pluign base on the demo.
77

8-
**插件就是一个普通的npm模块,不需要将hiproxy作为依赖安装到插件中。**
8+
**A plugin is a common npm module. You do not need to install hiproxy as a dependency.**
99

1010
<br />
1111

12-
## 插件结构
12+
## Plugin's architecture
1313

14-
hiproxy插件必须满足三个条件:
14+
Three condition should be satisfied before a module becomes a hiproxy pluign:
15+
16+
1. __It must be a standalone npm module which export only one object with three properties__
1517

16-
1. __插件必须作为一个独立的npm模块,这个模块需要导出一个对象,这个对象可以指定三个属性__
1718
```js
1819
module.exports = {
1920
// CLI commands
@@ -27,29 +28,28 @@ module.exports = {
2728
};
2829
```
2930

30-
* **commands**: `<Array>`,用来扩展`hiproxy`**CLI命令**,数组中每个对象作为一个命令配置,具体配置见[命令配置](./cli_command.html)
31+
* **commands**: `<Array>`, extends `hiproxy` **CLI**. Each element in the array should be a command configuration. See [Command Configuration](./cli_command.html) for details.
3132

32-
* **directives**: `<Array>`,用来扩展`hiproxy`**rewrite指令**,数组中每个对象作为一个指令配置,具体配置见[指令配置](./directive.html)
33+
* **directives**: `<Array>`, extends ***rewrite* directive** of `hiproxy`. Each element in the array should be a directive configuration. See [Rewrite Directive](./directive.html) for details.
3334

34-
* **routes**: `<Array>`,用来扩展`hiproxy`**页面路由**,数组中每个对象作为一个路由配置,具体配置见[路由配置](./route.html)
35+
* **routes**: `<Array>`, extends page router of `hiproxy`. Each element in the array should be a route configuration.See [Page Route Configuration](./route.html) for details.
3536

36-
2. __插件模块必须安装到全局__
37+
2. __Plugin module must be installed to global__
3738

38-
3. __插件名称必须以`hiproxy-plugin-`开头__
39+
3. __Plugin name should use `hiproxy-plugin-` as prefix__
3940

40-
## 代码示例
41+
## Code Example
4142

4243
<https://github.com/hiproxy/hiproxy-plugin-example/blob/master/index.js#L14-L23>
4344

44-
## 插件发布
45-
46-
插件开发、测试完成之后,可以将其发布到npm。
45+
## Publish Plugin
4746

48-
发布的过程和方法,跟其他npm模块的发布一样,因为hiproxy的插件,**就是一个**遵循了特定规则的**普通npm模块**
47+
You can publish a plugin into npm while it's completed with development and testing.
4948

49+
The publish process is the same as publishing other npm module, since the a plugin of hiproxy **is jsut** a **common npm module** which follows given rules.
5050

51-
## 温馨提示
51+
## Hint
5252

53-
由于hiproxy只会从`npm root -g`所在的目录去查找名称以`hiproxy-plugin-`开头的插件,所以在本地开发时,hiproxy加载不到新的插件。
53+
Hiproxy look for plugins which has `hiproxy-plugiin-` as prefix and installed in the directory described by `npm root -g`, so that hiproxy cannot find new developing pluigns.
5454

55-
可以使用`npm link`,创建一个符号链接,这样就能一边开发一边调试开发中的插件。详情请参考npm文档:[npm link](https://docs.npmjs.com/cli/link)
55+
`npm link` can create a symbol link of a plugin so that you can debug it while it's in development. See [npm link](https://docs.npmjs.com/cli/link) of npm document for details.

source/developers/route.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
1-
title: Route 页面路由配置
1+
title: Page Route Configuration
22
---
33

4-
> 如果你愿意帮助hiproxy编写文档,请联系zdying@live.com, 谢谢!
5-
>
64
> If you are willing to help hiproxy to write documentation, please contact zdying@live.com, thank you!
75
8-
## 简介
6+
## Introduction
97

10-
hiproxy启动服务之后,可以访问`http://127.0.0.1:<port>/`页面查看服务的一些基本信息。
8+
You can visit `http://127.0.0.1:<port>/` to watch basic informations of the service after it finished starting.
119

12-
除了上面的页面之外,hiproxy还提供了增加新页面的功能。比如插件[hiproxy-plugin-dashboard](https://github.com/hiproxy/hiproxy-plugin-dashboard),为hiproxy增加了一个在线查看服务信息以及修改配置文件的页面,地址为:`http://127.0.0.1:<port>/dashboard/`
10+
Except that page, hiproxy support a feature for adding new page. For example, plugin [hiproxy-plugin-dashboard](https://github.com/hiproxy/hiproxy-plugin-dashboard) add a page to hiproxy for showing service information and modifying configuration files, which is at `http://127.0.0.1:<port>/dashboard/`.
1311

12+
## Configuration Content
1413

15-
## 配置内容
14+
Page route configuration include: `route rules` and `renderer`. Then are:
1615

17-
页面路由可以配置的内容为:`路由规则``渲染函数`。对应的字段为:
16+
* Route Rules(route):`<String>`, URL pattern, i.e. `'/dashboard(/:page)'`. See <https://www.npmjs.com/package/url-pattern> for details.
17+
* Renderer(render):`<Function>`, for rendering a page. It accept three parameters: `(route, request, response)`.
1818

19-
* 路由规则(route):`<String>`,页面的地址模式,比如:`'/dashboard(/:page)'`,细节可以查看<https://www.npmjs.com/package/url-pattern>
20-
* 渲染函数(render):`<Function>`,渲染页面,接收三个参数:`(route, request, response)`
19+
## Renderer, render() Method
2120

22-
## render方法
21+
`render()` method should be invokded with three parameters, `(route, request, response)`, while user visit the corresponding page.
2322

24-
当用户访问对应的页面时,`render()`方法会被调用,传入三个参数`(route, request, response)`
23+
- **route**: `<Object>`, arguments object from route pattern. For example, `/test(/:pageName)` pattern cause the object `{pageName: 'home'}` while `/test/home` is visiting.
24+
- **request**: `<http.IncomingMessage>`,http request instance.
25+
- **response**: `<http.ServerResponse>`,http response instance.
2526

26-
- **route**: `<Object>`,url模式匹配后的对象,比如配置了`/test(/:pageName)`之后,访问`/test/home``route`的值为:`{pageName: 'home'}`
27-
- **request**: `<http.IncomingMessage>`,http请求对象。
28-
- **response**: `<http.ServerResponse>`,http响应对象。
27+
## Example
2928

30-
## 示例
31-
32-
一个完整的页面扩展示例如下:
29+
A entire example is below:
3330

3431
```js
3532
{
3633
route: '/test(/:pageName)',
3734
render: function (route, request, response) {
38-
   // 这里面可以使用全局变量`hiproxyServer`来获取hiproxy服务实例
35+
   // global variable `hiproxyServer` can be used to get hiproxy server instance.
3936
   response.writeHead(200, {
4037
'Content-Type': 'text/html',
4138
'Powder-By': 'hiproxy-plugin-example'

0 commit comments

Comments
 (0)