[incubator-apisix] branch master updated: luacov: add new path `plugins/limit-count` and `plugins/utils`. (#1357)

2020-03-28 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new aa13b72  luacov: add new path `plugins/limit-count` and 
`plugins/utils`. (#1357)
aa13b72 is described below

commit aa13b72c0da970fafd869fee3b4a2fe1f6c3963f
Author: YuanSheng Wang 
AuthorDate: Sun Mar 29 10:58:11 2020 +0800

luacov: add new path `plugins/limit-count` and `plugins/utils`. (#1357)
---
 t/apisix.luacov | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/t/apisix.luacov b/t/apisix.luacov
index 8f4f58f..cdddc10 100644
--- a/t/apisix.luacov
+++ b/t/apisix.luacov
@@ -24,8 +24,10 @@ return {
 ["lua/apisix/http/router/*"] = "http/router",
 ["lua/apisix/plugins/*"] = "plugins",
 ["lua/apisix/plugins/grpc-transcode/*"] = "plugins/grpc-transcode",
+["lua/apisix/plugins/limit-count/*"] = "plugins/limit-count",
 ["lua/apisix/plugins/prometheus/*"] = "plugins/prometheus",
 ["lua/apisix/plugins/zipkin/*"] = "plugins/zipkin",
+["lua/apisix/utils/*"] = "utils",
 
 -- can not enable both at http and stream, will fix it later.
 --  ["lua/apisix/stream/*"] = "stream",



[GitHub] [incubator-apisix] membphis merged pull request #1357: luacov: add new path `plugins/limit-count` and `plugins/utils`.

2020-03-28 Thread GitBox
membphis merged pull request #1357: luacov: add new path `plugins/limit-count` 
and `plugins/utils`.
URL: https://github.com/apache/incubator-apisix/pull/1357
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[incubator-apisix] branch master updated: feature: add cors plugin (#1327)

2020-03-28 Thread wenming
This is an automated email from the ASF dual-hosted git repository.

wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new c363ea4  feature: add cors plugin (#1327)
c363ea4 is described below

commit c363ea46d925b8efa4b7197d2679649dd6d51f0c
Author: Vinci Xu <277040...@qq.com>
AuthorDate: Sun Mar 29 10:30:59 2020 +0800

feature: add cors plugin (#1327)
---
 README.md   |   1 +
 README_CN.md|   1 +
 conf/config.yaml|   2 +-
 doc/README.md   |   1 +
 doc/README_CN.md|   1 +
 doc/plugins/cors-cn.md  |  93 ++
 doc/plugins/cors.md |  95 ++
 lua/apisix/plugins/cors.lua | 136 ++
 t/admin/plugins.t   |   2 +-
 t/debug/debug-mode.t|   1 +
 t/plugin/cors.t | 428 
 11 files changed, 759 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 4ccbf88..1d6bc1d 100644
--- a/README.md
+++ b/README.md
@@ -90,6 +90,7 @@ A/B testing, canary release, blue-green deployment, limit 
rate, defense against
 - [Limit-count](doc/plugins/limit-count.md)
 - [Limit-concurrency](doc/plugins/limit-conn.md)
 - Anti-ReDoS(Regular expression Denial of Service): Built-in policies to 
Anti ReDoS without configuration.
+- [CORS](doc/plugins/cors.md)
 
 - **OPS friendly**
 - OpenTracing: [support Apache Skywalking and 
Zipkin](doc/plugins/zipkin.md)
diff --git a/README_CN.md b/README_CN.md
index 1f85fbb..1296f26 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -90,6 +90,7 @@ A/B 测试、金丝雀发布(灰度发布)、蓝绿部署、限流限速、抵
 - [限制请求数](doc/plugins/limit-count-cn.md)
 - [限制并发](doc/plugins/limit-conn-cn.md)
 - 防御 ReDoS(正则表达式拒绝服务):内置策略,无需配置即可抵御 ReDoS。
+- [CORS](doc/plugins/cors-cn.md)
 
 - **运维友好**
 - OpenTracing 可观测性: [支持 Apache Skywalking 和 
Zipkin](doc/plugins/zipkin-cn.md)。
diff --git a/conf/config.yaml b/conf/config.yaml
index e76a3aa..a54eb12 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -144,6 +144,6 @@ plugins:  # plugin list
   - tcp-logger
   - proxy-mirror
   - kafka-logger
-
+  - cors
 stream_plugins:
   - mqtt-proxy
diff --git a/doc/README.md b/doc/README.md
index ad83c5b..40da08e 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -63,6 +63,7 @@ Plugins
 * [udp-logger](plugins/udp-logger.md): Log requests to UDP servers.
 * [proxy-mirror](plugins/proxy-mirror.md): Provides the ability to mirror 
client requests.
 * [kafka-logger](plugins/kafka-logger.md): Log requests to External Kafka 
servers.
+* [cors](plugins/cors.md): Enbale cors for you api.
 
 Deploy to the Cloud
 ===
diff --git a/doc/README_CN.md b/doc/README_CN.md
index f063486..bf31414 100644
--- a/doc/README_CN.md
+++ b/doc/README_CN.md
@@ -64,3 +64,4 @@ Reference document
 * [udp-logger](plugins/udp-logger.md): 将请求记录到UDP服务器
 * [tcp-logger](plugins/tcp-logger.md): 将请求记录到TCP服务器
 * [kafka-logger](plugins/kafka-logger-cn.md): 将请求记录到外部Kafka服务器。
+* [cors](plugins/cors-cn.md): 为你的API启用CORS.
diff --git a/doc/plugins/cors-cn.md b/doc/plugins/cors-cn.md
new file mode 100644
index 000..413dc95
--- /dev/null
+++ b/doc/plugins/cors-cn.md
@@ -0,0 +1,93 @@
+
+
+# [English](cors.md)
+
+# 目录
+
+- [**简介**](#简介)
+- [**属性**](#属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`cors` 插件可以让你轻易地为服务端启用 
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) 的返回头。
+
+## 属性
+
+- `allow_origins`: `可选`,允许跨域访问的 Origin,格式如:`scheme`://`host`:`port`,比如: 
https://somehost.com:8081。多个值使用 `,` 分割,`allow_credential` 为 `false` 时可以使用 `*` 
来表示所有 Origin 均允许通过。你也可以在启用了 `allow_credential` 后使用 `**` 强制允许所有 Origin 
都通过,但请注意这样存在安全隐患。默认值为 `*`。
+- `allow_methods`: `可选`,允许跨域访问的 Method,比如: `GET`,`POST`等。多个值使用 `,` 
分割,`allow_credential` 为 `false` 时可以使用 `*` 来表示所有 Origin 均允许通过。你也可以在启用了 
`allow_credential` 后使用 `**` 强制允许所有 Method 都通过,但请注意这样存在安全隐患。默认值为 `*`。
+- `allow_headers`: `可选`,允许跨域访问时请求方携带哪些非 `CORS规范` 以外的 Header, 多个值使用 `,` 分割。默认值为 
`*`。
+- `expose_headers`: `可选`,允许跨域访问时响应方携带哪些非 `CORS规范` 以外的 Header, 多个值使用 `,` 
分割。默认值为 `*`。
+- `max_age`: `可选`,浏览器缓存 CORS 结果的最大时间,单位为秒,在这个时间范围内浏览器会复用上一次的检查结果,`-1` 
表示不缓存。请注意各个浏览器允许的的最大时间不用,详情请参考 
[MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age#Directives).
 默认值为 `5`。
+- `allow_credential`: 是否允许跨域访问的请求方携带凭据(如 Cookie 等),默认值为: `false`。
+
+## 如何启用
+
+创建 `Route` 或 `Service` 对象,并配置 `cors` 插件。
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+"uri": "/hello",
+"plugins": {
+"cors": {}
+},
+"upstream": {
+"type": "roundrobin",
+"nodes": {
+"127.0.0.1:8080": 1
+}
+}
+}'
+```
+
+## 测试插件
+
+请求下接口,发现接口已经返回了`CORS`相关的header,代表插件生效
+```shell
+curl http://127.0.0.1:9080/hello -v
+...
+< Server: APISIX web 

[GitHub] [incubator-apisix] moonming merged pull request #1327: features: append cors plugin

2020-03-28 Thread GitBox
moonming merged pull request #1327: features: append cors plugin
URL: https://github.com/apache/incubator-apisix/pull/1327
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] moonming commented on a change in pull request #1351: [WIP]feature: remove `lua` dir.

2020-03-28 Thread GitBox
moonming commented on a change in pull request #1351: [WIP]feature: remove 
`lua` dir.
URL: https://github.com/apache/incubator-apisix/pull/1351#discussion_r399734871
 
 

 ##
 File path: Contributing.md
 ##
 @@ -98,15 +98,15 @@ Once we've discussed your changes and you've got your code 
ready, make sure that
 $ make lint
 luacheck -q lua
 Total: 0 warnings / 0 errors in 74 files
-./utils/lj-releng lua/*.lua \
-lua/apisix/*.lua \
-lua/apisix/admin/*.lua \
-lua/apisix/core/*.lua \
-lua/apisix/http/*.lua \
-lua/apisix/http/router/*.lua \
-lua/apisix/plugins/*.lua \
-lua/apisix/plugins/grpc-transcode/*.lua \
-lua/apisix/plugins/limit-count/*.lua > \
+./utils/lj-releng \
 
 Review comment:
   moved `apisix.lua` to `apisix/init.lua`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] moonming commented on issue #1351: [WIP]feature: remove `lua` dir.

2020-03-28 Thread GitBox
moonming commented on issue #1351: [WIP]feature: remove `lua` dir.
URL: https://github.com/apache/incubator-apisix/pull/1351#issuecomment-605546703
 
 
   > > `lua/apisix.lua → apisix.lua `
   > 
   > How about `lua/apisix.lua → apisix/init.lua` ?
   
   good idea


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[incubator-apisix] branch master updated: dashboard: add dashboard as submodule. (#1360)

2020-03-28 Thread wenming
This is an automated email from the ASF dual-hosted git repository.

wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 7ff43d5  dashboard: add dashboard as submodule. (#1360)
7ff43d5 is described below

commit 7ff43d51ca1251a3969c2dc587df3ce4c30f5a25
Author: Wen Ming 
AuthorDate: Sun Mar 29 10:06:42 2020 +0800

dashboard: add dashboard as submodule. (#1360)
---
 .gitignore  | 1 -
 .gitmodules | 3 ++-
 .travis/ASF-Release.cfg | 3 +++
 dashboard   | 1 +
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index f3c389a..8327a3f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,7 +55,6 @@ client_body_temp
 utils/lj-releng
 .idea/
 *.iml
-dashboard/
 \.*
 
 # .travis
diff --git a/.gitmodules b/.gitmodules
index 73b8155..31a8b7e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,4 @@
 [submodule "dashboard"]
path = dashboard
-   url = https://github.com/apache/incubator-apisix-dashboard-built.git
+   url = https://github.com/apache/incubator-apisix-dashboard.git
+
diff --git a/.travis/ASF-Release.cfg b/.travis/ASF-Release.cfg
index 703a361..5021dab 100644
--- a/.travis/ASF-Release.cfg
+++ b/.travis/ASF-Release.cfg
@@ -91,6 +91,9 @@ t/servroot
 conf
 .travis/openwhisk-utilities
 
+# Exclude dashboard files
+dashboard
+
 [Options]
 # Not all code files allow licenses to appear starting at the first character
 # of the file. This option tells the scan to allow licenses to appear starting
diff --git a/dashboard b/dashboard
new file mode 16
index 000..cfb3ee7
--- /dev/null
+++ b/dashboard
@@ -0,0 +1 @@
+Subproject commit cfb3ee7b8721076975c1deaff3e52da3ea4a312a



[GitHub] [incubator-apisix] moonming merged pull request #1360: dashboard: add dashboard as submodule.

2020-03-28 Thread GitBox
moonming merged pull request #1360: dashboard: add dashboard as submodule.
URL: https://github.com/apache/incubator-apisix/pull/1360
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] nic-chen closed issue #1144: request help: fail to proxy grpc request

2020-03-28 Thread GitBox
nic-chen closed issue #1144: request help:  fail to proxy grpc request
URL: https://github.com/apache/incubator-apisix/issues/1144
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] nic-chen commented on issue #1144: request help: fail to proxy grpc request

2020-03-28 Thread GitBox
nic-chen commented on issue #1144: request help:  fail to proxy grpc request
URL: 
https://github.com/apache/incubator-apisix/issues/1144#issuecomment-605543060
 
 
   duplicate issue with  #1209
   
   close. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] moonming opened a new pull request #1360: dashboard: add dashboard as submodule.

2020-03-28 Thread GitBox
moonming opened a new pull request #1360: dashboard: add dashboard as submodule.
URL: https://github.com/apache/incubator-apisix/pull/1360
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on issue #1327: features: append cors plugin

2020-03-28 Thread GitBox
membphis commented on issue #1327: features: append cors plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#issuecomment-605446526
 
 
   you should revert them:
   
   
![image](https://user-images.githubusercontent.com/6814606/77823941-c0cdaa80-7139-11ea-89fb-accfc4ccc292.png)
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] ShiningRush commented on issue #1327: features: append cors plugin

2020-03-28 Thread GitBox
ShiningRush commented on issue #1327: features: append cors plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#issuecomment-605435217
 
 
   The ci show the `./doc/plugins/cors-cn.md` has no license header, but it 
does have, hmm, what happened to it?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on issue #1281: feature: Support for using Eureka as a service discovery center

2020-03-28 Thread GitBox
membphis commented on issue #1281: feature: Support for using Eureka as a 
service discovery center
URL: https://github.com/apache/incubator-apisix/pull/1281#issuecomment-605421247
 
 
   ```
   .travis/openwhisk-utilities/scancode/scanCode.py --config 
.travis/ASF-Release.cfg ./
   Reading configuration file [.travis/ASF-Release.cfg]...
   Scanning files starting at [./]...
   Scan detected 2 error(s) in 2 file(s):
 [./doc/discovery-cn.md]:
130: line has trailing whitespace.
 [./lua/apisix/discovery/*.lua]:
  1: file does not include required license header.
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on issue #1351: [WIP]feature: remove `lua` dir.

2020-03-28 Thread GitBox
membphis commented on issue #1351: [WIP]feature: remove `lua` dir.
URL: https://github.com/apache/incubator-apisix/pull/1351#issuecomment-605421029
 
 
   > `lua/apisix.lua → apisix.lua `
   
   How about `lua/apisix.lua → apisix/init.lua` ?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on issue #1327: features: append cors plugin

2020-03-28 Thread GitBox
membphis commented on issue #1327: features: append cors plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#issuecomment-605420837
 
 
   add a reference to doc:
   
   https://github.com/apache/incubator-apisix#features


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on a change in pull request #1327: features: append cors plugin

2020-03-28 Thread GitBox
membphis commented on a change in pull request #1327: features: append cors 
plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#discussion_r399642693
 
 

 ##
 File path: doc/plugins/cors-cn.md
 ##
 @@ -0,0 +1,92 @@
+
+
+# [English](cors.md)
+
+# 目录
+
+- [**简介**](#简介)
+- [**属性**](#属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`cors` 插件可以让你轻易地为服务端启用 
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) 的返回头。
+
+## 属性
+
+- `allow_origins`: `可选`.允许跨域访问的Origin, 格式如:`scheme`://`host`:`port`, 比如: 
https://somehost.com:8081. 多个值使用 `,` 分割, `allow_credential` 为 `false` 时可以使用 `*` 
来表示所有 Origin均允许通过。你也可以在启用了 `allow_credential` 后使用 `**` 
强制允许所有Origin都通过,但请注意这样存在安全隐患。默认值为 `*`。
+- `allow_methods`: `可选`.允许跨域访问的Method, 比如: `GET`, `POST`等。多个值使用 `,` 分割, 
`allow_credential` 为 `false` 时可以使用 `*` 来表示所有 Origin均允许通过。你也可以在启用了 
`allow_credential` 后使用 `**` 强制允许所有 Method 都通过,但请注意这样存在安全隐患。默认值为 `*`。
+- `allow_headers`: `可选`.允许跨域访问时请求方携带哪些非 CORS规范 以外的 Header,  多个值使用 `,` 分割。默认值为 
`*`。
+- `expose_headers`: `可选`.允许跨域访问时响应方携带哪些非 CORS规范 以外的 Header,  多个值使用 `,` 分割。默认值为 
`*`。
+- `max_age`: `可选`.浏览器缓存CORS结果的最大时间, 单位为秒, 在这个时间范围内浏览器会复用上一次的检查结果, `-1` 
表示不缓存。请注意各个浏览器允许的的最大时间不用, 详情请参考 
[MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age#Directives).
 默认值为 `5`。
+- `allow_credential`: 是否允许跨域访问的请求方携带凭据(如 Cookie 等), 默认值为: `false`。
+
+## 如何启用
+创建 `Route` 或 `Service` 对象,并配置 `cors` 插件。
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+"methods": ["GET"],
 
 Review comment:
   we can remove this line


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on a change in pull request #1327: features: append cors plugin

2020-03-28 Thread GitBox
membphis commented on a change in pull request #1327: features: append cors 
plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#discussion_r399642598
 
 

 ##
 File path: doc/plugins/cors-cn.md
 ##
 @@ -0,0 +1,92 @@
+
+
+# [English](cors.md)
+
+# 目录
+
+- [**简介**](#简介)
+- [**属性**](#属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`cors` 插件可以让你轻易地为服务端启用 
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) 的返回头。
+
+## 属性
+
+- `allow_origins`: `可选`.允许跨域访问的Origin, 格式如:`scheme`://`host`:`port`, 比如: 
https://somehost.com:8081. 多个值使用 `,` 分割, `allow_credential` 为 `false` 时可以使用 `*` 
来表示所有 Origin均允许通过。你也可以在启用了 `allow_credential` 后使用 `**` 
强制允许所有Origin都通过,但请注意这样存在安全隐患。默认值为 `*`。
 
 Review comment:
   Use Chinese commas


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on a change in pull request #1327: features: append cors plugin

2020-03-28 Thread GitBox
membphis commented on a change in pull request #1327: features: append cors 
plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#discussion_r399642697
 
 

 ##
 File path: doc/plugins/cors-cn.md
 ##
 @@ -0,0 +1,92 @@
+
+
+# [English](cors.md)
+
+# 目录
+
+- [**简介**](#简介)
+- [**属性**](#属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`cors` 插件可以让你轻易地为服务端启用 
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) 的返回头。
+
+## 属性
+
+- `allow_origins`: `可选`.允许跨域访问的Origin, 格式如:`scheme`://`host`:`port`, 比如: 
https://somehost.com:8081. 多个值使用 `,` 分割, `allow_credential` 为 `false` 时可以使用 `*` 
来表示所有 Origin均允许通过。你也可以在启用了 `allow_credential` 后使用 `**` 
强制允许所有Origin都通过,但请注意这样存在安全隐患。默认值为 `*`。
+- `allow_methods`: `可选`.允许跨域访问的Method, 比如: `GET`, `POST`等。多个值使用 `,` 分割, 
`allow_credential` 为 `false` 时可以使用 `*` 来表示所有 Origin均允许通过。你也可以在启用了 
`allow_credential` 后使用 `**` 强制允许所有 Method 都通过,但请注意这样存在安全隐患。默认值为 `*`。
+- `allow_headers`: `可选`.允许跨域访问时请求方携带哪些非 CORS规范 以外的 Header,  多个值使用 `,` 分割。默认值为 
`*`。
+- `expose_headers`: `可选`.允许跨域访问时响应方携带哪些非 CORS规范 以外的 Header,  多个值使用 `,` 分割。默认值为 
`*`。
+- `max_age`: `可选`.浏览器缓存CORS结果的最大时间, 单位为秒, 在这个时间范围内浏览器会复用上一次的检查结果, `-1` 
表示不缓存。请注意各个浏览器允许的的最大时间不用, 详情请参考 
[MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age#Directives).
 默认值为 `5`。
+- `allow_credential`: 是否允许跨域访问的请求方携带凭据(如 Cookie 等), 默认值为: `false`。
+
+## 如何启用
+创建 `Route` 或 `Service` 对象,并配置 `cors` 插件。
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+"methods": ["GET"],
+"uri": "/hello",
+"plugins": {
+"cors": {}
+},
+"upstream": {
+"type": "roundrobin",
+"nodes": {
+"127.0.0.1:8080": 1
+}
+}
+}'
+```
+
+## 测试插件
+请求下接口, 发现接口已经返回了`CORS`相关的header, 代表插件生效
+```shell
+curl http://127.0.0.1:9080/hello -v
+...
+< Server: APISIX web server
+< Access-Control-Allow-Origin: *
+< Access-Control-Allow-Methods: *
+< Access-Control-Allow-Headers: *
+< Access-Control-Expose-Headers: *
+< Access-Control-Max-Age: 5
+...
+```
+
+## 禁用插件
+
+从配置中移除`cors`插件即可。
+```shell
+$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+"methods": ["GET"],
 
 Review comment:
   we can remove this line


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on a change in pull request #1327: features: append cors plugin

2020-03-28 Thread GitBox
membphis commented on a change in pull request #1327: features: append cors 
plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#discussion_r399642450
 
 

 ##
 File path: doc/plugins/cors-cn.md
 ##
 @@ -0,0 +1,92 @@
+
+
+# [English](cors.md)
+
+# 目录
+
+- [**简介**](#简介)
+- [**属性**](#属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`cors` 插件可以让你轻易地为服务端启用 
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) 的返回头。
+
+## 属性
+
+- `allow_origins`: `可选`.允许跨域访问的Origin, 格式如:`scheme`://`host`:`port`, 比如: 
https://somehost.com:8081. 多个值使用 `,` 分割, `allow_credential` 为 `false` 时可以使用 `*` 
来表示所有 Origin均允许通过。你也可以在启用了 `allow_credential` 后使用 `**` 
强制允许所有Origin都通过,但请注意这样存在安全隐患。默认值为 `*`。
 
 Review comment:
   "`可选`. " -> "`可选`,"


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on a change in pull request #1327: features: append cors plugin

2020-03-28 Thread GitBox
membphis commented on a change in pull request #1327: features: append cors 
plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#discussion_r399642628
 
 

 ##
 File path: doc/plugins/cors-cn.md
 ##
 @@ -0,0 +1,92 @@
+
+
+# [English](cors.md)
+
+# 目录
+
+- [**简介**](#简介)
+- [**属性**](#属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`cors` 插件可以让你轻易地为服务端启用 
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) 的返回头。
+
+## 属性
+
+- `allow_origins`: `可选`.允许跨域访问的Origin, 格式如:`scheme`://`host`:`port`, 比如: 
https://somehost.com:8081. 多个值使用 `,` 分割, `allow_credential` 为 `false` 时可以使用 `*` 
来表示所有 Origin均允许通过。你也可以在启用了 `allow_credential` 后使用 `**` 
强制允许所有Origin都通过,但请注意这样存在安全隐患。默认值为 `*`。
 
 Review comment:
   add space between English and Chinese


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on a change in pull request #1327: features: append cors plugin

2020-03-28 Thread GitBox
membphis commented on a change in pull request #1327: features: append cors 
plugin
URL: https://github.com/apache/incubator-apisix/pull/1327#discussion_r399642650
 
 

 ##
 File path: doc/plugins/cors-cn.md
 ##
 @@ -0,0 +1,92 @@
+
+
+# [English](cors.md)
+
+# 目录
+
+- [**简介**](#简介)
+- [**属性**](#属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`cors` 插件可以让你轻易地为服务端启用 
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) 的返回头。
+
+## 属性
+
+- `allow_origins`: `可选`.允许跨域访问的Origin, 格式如:`scheme`://`host`:`port`, 比如: 
https://somehost.com:8081. 多个值使用 `,` 分割, `allow_credential` 为 `false` 时可以使用 `*` 
来表示所有 Origin均允许通过。你也可以在启用了 `allow_credential` 后使用 `**` 
强制允许所有Origin都通过,但请注意这样存在安全隐患。默认值为 `*`。
+- `allow_methods`: `可选`.允许跨域访问的Method, 比如: `GET`, `POST`等。多个值使用 `,` 分割, 
`allow_credential` 为 `false` 时可以使用 `*` 来表示所有 Origin均允许通过。你也可以在启用了 
`allow_credential` 后使用 `**` 强制允许所有 Method 都通过,但请注意这样存在安全隐患。默认值为 `*`。
+- `allow_headers`: `可选`.允许跨域访问时请求方携带哪些非 CORS规范 以外的 Header,  多个值使用 `,` 分割。默认值为 
`*`。
+- `expose_headers`: `可选`.允许跨域访问时响应方携带哪些非 CORS规范 以外的 Header,  多个值使用 `,` 分割。默认值为 
`*`。
+- `max_age`: `可选`.浏览器缓存CORS结果的最大时间, 单位为秒, 在这个时间范围内浏览器会复用上一次的检查结果, `-1` 
表示不缓存。请注意各个浏览器允许的的最大时间不用, 详情请参考 
[MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age#Directives).
 默认值为 `5`。
+- `allow_credential`: 是否允许跨域访问的请求方携带凭据(如 Cookie 等), 默认值为: `false`。
+
+## 如何启用
+创建 `Route` 或 `Service` 对象,并配置 `cors` 插件。
 
 Review comment:
   add a blank line


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] chnliyong commented on a change in pull request #1351: [WIP]feature: remove `lua` dir.

2020-03-28 Thread GitBox
chnliyong commented on a change in pull request #1351: [WIP]feature: remove 
`lua` dir.
URL: https://github.com/apache/incubator-apisix/pull/1351#discussion_r399628666
 
 

 ##
 File path: bin/apisix
 ##
 @@ -113,9 +113,8 @@ env APISIX_PROFILE;
 
 {% if stream_proxy then %}
 stream {
-lua_package_path  
"$prefix/deps/share/lua/5.1/?.lua;/usr/share/lua/5.1/apisix/lua/?.lua;]=]
-  .. [=[/usr/local/share/lua/5.1/apisix/lua/?.lua;]=]
-  .. [=[$prefix/deps/share/lua/5.1/apisix/lua/?.lua;]=]
+lua_package_path  "$prefix/deps/share/lua/5.1/?.lua;]=]
+  .. [=[$prefix/deps/share/lua/5.1/apisix/?.lua;]=]
 
 Review comment:
   line 61 `pkg_path  = apisix_home .. "/lua/?.lua;"` also need to change to 
`pkg_path  = apisix_home .. "/?.lua;"`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on issue #1351: [WIP]feature: remove `lua` dir.

2020-03-28 Thread GitBox
membphis commented on issue #1351: [WIP]feature: remove `lua` dir.
URL: https://github.com/apache/incubator-apisix/pull/1351#issuecomment-605403364
 
 
   > Will this conflict with other luarocks libraries?
   
   No conflict. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-apisix] membphis commented on a change in pull request #1351: [WIP]feature: remove `lua` dir.

2020-03-28 Thread GitBox
membphis commented on a change in pull request #1351: [WIP]feature: remove 
`lua` dir.
URL: https://github.com/apache/incubator-apisix/pull/1351#discussion_r399626651
 
 

 ##
 File path: Makefile
 ##
 @@ -117,47 +117,47 @@ install:
$(INSTALL) conf/config.yaml /usr/local/apisix/conf/config.yaml
$(INSTALL) conf/cert/apisix.* /usr/local/apisix/conf/cert/
 
-   $(INSTALL) -d $(INST_LUADIR)/apisix/lua
-   $(INSTALL) lua/*.lua $(INST_LUADIR)/apisix/lua/
+   $(INSTALL) -d $(INST_LUADIR)/apisix
+   $(INSTALL) *.lua $(INST_LUADIR)/apisix/
 
-   $(INSTALL) -d $(INST_LUADIR)/apisix/lua/apisix
-   $(INSTALL) lua/apisix/*.lua $(INST_LUADIR)/apisix/lua/apisix/
+   $(INSTALL) -d $(INST_LUADIR)/apisix/apisix
+   $(INSTALL) apisix/*.lua $(INST_LUADIR)/apisix/apisix/
 
 Review comment:
   we should install source code to `$(INST_LUADIR)/apisix/`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services