You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/01 07:58:23 UTC

[GitHub] [apisix] hf400159 commented on a diff in pull request #7577: docs: add public-api.md

hf400159 commented on code in PR #7577:
URL: https://github.com/apache/apisix/pull/7577#discussion_r933802507


##########
docs/zh/latest/plugins/public-api.md:
##########
@@ -0,0 +1,165 @@
+---
+title: public-api
+keywords:
+  - APISIX
+  - API 网关
+  - Public API
+  - public-api
+description: public-api 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## 描述
+
+`public-api` 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+
+当你使用自定义插件时,你可以使用 `public-api` 插件为特定功能定义一个固定的公共 API。例如,你可以使用 [`jwt-auth`](./jwt-auth.md) 插件创建一个公共 API 端点 `/apisix/plugin/jwt/sign` 用于 JWT 认证。

Review Comment:
   ```suggestion
   你可以通过在路由中添加 `public-api` 插件,来保护**自定义插件为了实现特定功能**而暴露的 API。例如,你可以使用 [`jwt-auth`](./jwt-auth.md) 插件创建一个公共 API 端点 `/apisix/plugin/jwt/sign` 用于 JWT 认证。
   ```



##########
docs/zh/latest/plugins/public-api.md:
##########
@@ -0,0 +1,165 @@
+---
+title: public-api
+keywords:
+  - APISIX
+  - API 网关
+  - Public API
+  - public-api
+description: public-api 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## 描述
+
+`public-api` 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。

Review Comment:
   ```suggestion
   `public-api` 插件可用于通过创建路由的方式暴露用户自定义的 API。
   ```



##########
docs/zh/latest/plugins/public-api.md:
##########
@@ -0,0 +1,165 @@
+---
+title: public-api
+keywords:
+  - APISIX
+  - API 网关
+  - Public API
+  - public-api
+description: public-api 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## 描述
+
+`public-api` 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+
+当你使用自定义插件时,你可以使用 `public-api` 插件为特定功能定义一个固定的公共 API。例如,你可以使用 [`jwt-auth`](./jwt-auth.md) 插件创建一个公共 API 端点 `/apisix/plugin/jwt/sign` 用于 JWT 认证。
+
+默认情况下,在自定义插件中添加的公共 API 是不公开的,用户需要手动配置一个路由并在上面启用 `public-api` 插件。
+
+## 属性
+
+| 名称  | 类型   | 必选项    | 默认值   | 描述                                                        |
+|------|--------|----------|---------|------------------------------------------------------------|
+| uri  | string | 否       | ""      | 公共 API 的 URI。在设置路由时,使用此属性来配置初始的公共 API URI。 |
+
+## 启用插件
+
+除了 `public-api` 插件,下面的例子也使用了 [`jwt-auth`](./jwt-auth.md) 和 [`key-auth`](./key-auth.md) 插件,详细使用方法请参考它们对应的文档。
+
+### 基本用法
+
+以下示例展示了如何在指定路由上启用并配置 `public-api` 插件:
+
+```shell
+curl -X PUT 'http://127.0.0.1:9080/apisix/admin/routes/r1' \
+    -H 'X-API-KEY: <api-key>' \

Review Comment:
   Please use `${variable}` for variables, or use the default key.



##########
docs/zh/latest/plugins/public-api.md:
##########
@@ -0,0 +1,165 @@
+---
+title: public-api
+keywords:
+  - APISIX
+  - API 网关
+  - Public API
+  - public-api

Review Comment:
   ```suggestion
   ```



##########
docs/zh/latest/plugins/public-api.md:
##########
@@ -0,0 +1,165 @@
+---
+title: public-api
+keywords:
+  - APISIX
+  - API 网关
+  - Public API
+  - public-api
+description: public-api 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。

Review Comment:
   ```suggestion
   description: 本文介绍了 public-api 的相关操作,你可以使用 public-api 插件保护你需要暴露的 API 的端点。
   ```



##########
docs/zh/latest/plugins/public-api.md:
##########
@@ -0,0 +1,165 @@
+---
+title: public-api
+keywords:
+  - APISIX
+  - API 网关
+  - Public API
+  - public-api
+description: public-api 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## 描述
+
+`public-api` 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+
+当你使用自定义插件时,你可以使用 `public-api` 插件为特定功能定义一个固定的公共 API。例如,你可以使用 [`jwt-auth`](./jwt-auth.md) 插件创建一个公共 API 端点 `/apisix/plugin/jwt/sign` 用于 JWT 认证。
+
+默认情况下,在自定义插件中添加的公共 API 是不公开的,用户需要手动配置一个路由并在上面启用 `public-api` 插件。
+
+## 属性
+
+| 名称  | 类型   | 必选项    | 默认值   | 描述                                                        |
+|------|--------|----------|---------|------------------------------------------------------------|
+| uri  | string | 否       | ""      | 公共 API 的 URI。在设置路由时,使用此属性来配置初始的公共 API URI。 |
+
+## 启用插件
+
+除了 `public-api` 插件,下面的例子也使用了 [`jwt-auth`](./jwt-auth.md) 和 [`key-auth`](./key-auth.md) 插件,详细使用方法请参考它们对应的文档。
+
+### 基本用法
+
+以下示例展示了如何在指定路由上启用并配置 `public-api` 插件:
+
+```shell
+curl -X PUT 'http://127.0.0.1:9080/apisix/admin/routes/r1' \
+    -H 'X-API-KEY: <api-key>' \

Review Comment:
   ```suggestion
       -H 'X-API-KEY: ${api-key>} \
   ```



##########
docs/zh/latest/plugins/public-api.md:
##########
@@ -0,0 +1,165 @@
+---
+title: public-api
+keywords:
+  - APISIX
+  - API 网关
+  - Public API
+  - public-api
+description: public-api 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## 描述
+
+`public-api` 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+
+当你使用自定义插件时,你可以使用 `public-api` 插件为特定功能定义一个固定的公共 API。例如,你可以使用 [`jwt-auth`](./jwt-auth.md) 插件创建一个公共 API 端点 `/apisix/plugin/jwt/sign` 用于 JWT 认证。
+
+默认情况下,在自定义插件中添加的公共 API 是不公开的,用户需要手动配置一个路由并在上面启用 `public-api` 插件。

Review Comment:
   默认情况下,在自定义插件中添加的公共 API 不对外暴露的,你需要手动配置一个路由并启用 `public-api` 插件。



##########
docs/zh/latest/plugins/public-api.md:
##########
@@ -0,0 +1,165 @@
+---
+title: public-api
+keywords:
+  - APISIX
+  - API 网关
+  - Public API
+  - public-api
+description: public-api 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## 描述
+
+`public-api` 插件用于通过一个通用的 HTTP API 路由暴露一个 API 端点。
+
+当你使用自定义插件时,你可以使用 `public-api` 插件为特定功能定义一个固定的公共 API。例如,你可以使用 [`jwt-auth`](./jwt-auth.md) 插件创建一个公共 API 端点 `/apisix/plugin/jwt/sign` 用于 JWT 认证。
+
+默认情况下,在自定义插件中添加的公共 API 是不公开的,用户需要手动配置一个路由并在上面启用 `public-api` 插件。
+
+## 属性
+
+| 名称  | 类型   | 必选项    | 默认值   | 描述                                                        |
+|------|--------|----------|---------|------------------------------------------------------------|
+| uri  | string | 否       | ""      | 公共 API 的 URI。在设置路由时,使用此属性来配置初始的公共 API URI。 |
+
+## 启用插件
+
+除了 `public-api` 插件,下面的例子也使用了 [`jwt-auth`](./jwt-auth.md) 和 [`key-auth`](./key-auth.md) 插件,详细使用方法请参考它们对应的文档。
+
+### 基本用法
+
+以下示例展示了如何在指定路由上启用并配置 `public-api` 插件:
+
+```shell
+curl -X PUT 'http://127.0.0.1:9080/apisix/admin/routes/r1' \
+    -H 'X-API-KEY: <api-key>' \
+    -H 'Content-Type: application/json' \
+    -d '{
+    "uri": "/apisix/plugin/jwt/sign",
+    "plugins": {
+        "public-api": {}
+    }
+}'
+```
+
+**测试插件**

Review Comment:
   Should a consumer need to be created? Otherwise, the test cannot be performed.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org