Skip to content

Commit

Permalink
在帮助文档中新增动态添加请求头用法
Browse files Browse the repository at this point in the history
  • Loading branch information
getActivity committed Feb 13, 2025
1 parent bd0bfd7 commit 167f6b9
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions HelpDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

* [如何传入请求头](#如何传入请求头)

* [如何传入动态的请求头](#如何传入动态的请求头)

* [如何重命名参数或者请求头的名称](#如何重命名参数或者请求头的名称)

* [如何上传文件](#如何上传文件)
Expand Down Expand Up @@ -1079,9 +1081,27 @@ public final class XxxApi implements IRequestApi {
}
```

#### 如何传入动态的请求头

* 定义一个字段,并在上面添加 `@HTTPHeader` 注解即可

```java
public final class XxxApi implements IRequestApi {

@NonNull
@Override
public String getApi() {
return "xxx/xxxx";
}

@HttpHeader
private String time;
}
```

#### 如何重命名参数或者请求头的名称

* 给字段加上 `@HttpRename` 注解即可,则可以修改参数名的值,如果没有加上此注解,则框架默认使用字段名作为参数名
* 传入一个 HashMap 类型的字段,并在上面添加 `@HTTPHeader` 注解即可

```java
public final class XxxApi implements IRequestApi {
Expand All @@ -1092,8 +1112,8 @@ public final class XxxApi implements IRequestApi {
return "xxx/xxxx";
}

@HttpRename("k")
private String keyword;
@HTTPHeader
private HashMap<String,String> headers;
}
```

Expand Down

0 comments on commit 167f6b9

Please sign in to comment.