You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/07/11 09:43:03 UTC

[servicecomb-website] branch master updated: 修改错误答案

This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d7d644  修改错误答案
2d7d644 is described below

commit 2d7d644188ca4b7f6d19012ef6e57ed6751dd679
Author: liubao <bi...@qq.com>
AuthorDate: Thu Jul 11 17:34:27 2019 +0800

    修改错误答案
---
 _faqs/cn/faq.md | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/_faqs/cn/faq.md b/_faqs/cn/faq.md
index 3f63b94..7d291eb 100755
--- a/_faqs/cn/faq.md
+++ b/_faqs/cn/faq.md
@@ -494,18 +494,8 @@ redirect_from:
 
 * **Q: 如何在用户自定义的handler中获取header中某个字段的值**
 
-   A: 在用户自定义的handler使用@ApiImplicitParams注解声明,使用invocation.getArgs()获取header的值。例如:
-
-  ```java
-  public class MyHandler implements Handler {
-    @ApiImplicitParams({@ApiImplicitParam(name = "tester", dataType = "string", paramType = "header")})
-    @Override
-    public void handle(Invocation invocation, AsyncResponse asyncResp) throws Exception {
-      Object[] args = invocation.getArgs();
-      System.out.println(args);
-    }
-  }
-  ```
+   A: Invocation.getArgs可以获取到接口定义里面声明的所有参数信息。在接口里面未定义的信息,比如额外的header,则需要通过InvocationContext来传递和获取。基本原理是实现HttpServerFilter将header设置到InvocationContext里面,然后在通过invocation.getContext获取。示例代码可以参考servicecomb-fence的 [AuthHandler 和 AuthenticationFilter](https://github.com/apache/servicecomb-fence/tree/master/api/edge-service/endpoint/src/main/java/org/apache/servicecomb/authentication/edge) 。
+   
 
 * **Q: 微服务运行时抛出异常:` java.lang.Error:not support def type:calss io.swagger.models.properties BaseIntegerProperty`?**