Skip to content

Commit ac9fe54

Browse files
authored
docs(hertz): args peekall api (#830)
1 parent 3f84672 commit ac9fe54

File tree

29 files changed

+57
-45
lines changed

29 files changed

+57
-45
lines changed

content/en/docs/hertz/tutorials/basic-feature/client.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func main() {
6868
| WithDialFunc | network.Dialer | set dialer function. |
6969
| WithHostClientConfigHook | nil | Set the hook function for re-configure the host client. |
7070

71-
7271
Sample Code:
7372

7473
```go
@@ -540,7 +539,7 @@ func main() {
540539

541540
## Streaming Read Response Content
542541

543-
Hertz's client supports streaming read HTTP response content.
542+
Hertz's client supports streaming read HTTP response content.
544543

545544
Since the client has the problem of multiplexing connections, if streaming is used, the connection will be handled by the user(`resp.BodyStream()` is encapsulated by connection) once streaming is used. There are some differences in the management of connections in the above case:
546545

content/en/docs/hertz/tutorials/basic-feature/context/request.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ The Args object provides the following methods to obtain/set `Query String` para
223223
|`func (a *Args) ParseBytes(b []byte)` |Parsing byte arrays and storing key value pairs in Args object |
224224
|`func (a *Args) Peek(key string) []byte` |Obtain the value of Args object key |
225225
|`func (a *Args) PeekExists(key string) (string, bool)` |Obtain the value of Args object key and its existence |
226+
|`func (a *Args) PeekAll(key string) [][]byte` | Obtain all values of Args object key |
226227
|`func (a *Args) Len() int`|Obtain the number of Args object key-value pairs |
227228
|`func (a *Args) AppendBytes(dst []byte) []byte` |Append Args object Query String to dst and return |
228229
|`func (a *Args) VisitAll(f func(key, value []byte))` |Visit all key value pairs of Args object |
@@ -252,6 +253,8 @@ h.GET("/user", func(c context.Context, ctx *app.RequestContext) {
252253
// 4. key == []byte("pets"), value == []byte("cat")
253254
})
254255

256+
pets := args.PeekAll("pets") // pets == [][]byte{[]byte("dog"), []byte("cat")}
257+
255258
// send information to io.Writer
256259
req := protocol.AcquireRequest()
257260
n, err := args.WriteTo(req.BodyWriter())

content/en/docs/hertz/tutorials/basic-feature/engine.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Hertz Server supports streaming write responses.
288288
Two methods are provided:
289289

290290
1. The user passes in a `io.Reader` through the `ctx.SetBodyStream` function in the handler, and then reads and writes data in blocks in a similar manner to the example code (using channel to control data partitioning and read/write order) **Note that data needs to be written asynchronously**.
291-
291+
292292
If the user knows the total length of the transmitted data in advance, they can pass in the length in the `ctx.SetBodyStream` function for streaming writing, as shown in the example code `/streamWrite1`.
293293

294294
If the user does not know the total length of the transmitted data in advance, they can pass in -1 in the `ctx.SetBodyStream` function to write the stream in the form of `Transfer-Encoding: chunked`, as shown in the example code `/streamWrite2`.

content/en/docs/hertz/tutorials/basic-feature/unit-test.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func TestPerformRequest(t *testing.T) {
114114

115115
When executing the [PerformRequest](#performarequest) function, functions such as `NewRecorder`, `Header`, `Write`, `WriteHeader`, `Flush` have already been called internally. The user only needs to call the `Result` function to obtain the returned `protocol.Response` object, and then perform unit testing.
116116

117-
### ResponseRecorder
117+
### ResponseRecorder
118118

119119
Used to record the response information of the handler, as follows:
120120

content/en/docs/hertz/tutorials/framework-exten/log/zerolog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,10 @@ func main() {
354354
filePath := filepath.Base(segments[0]) //filepath=="logger.go"
355355
}
356356
```
357+
357358
### WithCallerSkipFrameCount
358359

359-
`WithCallerSkipFrameCount` adds `caller` to `logger`'s Context. `CallerWithSkipFrameCount` is a method of zerolog's Context structure. It is used to add the caller's file name and line number in the log record, and uses `zerolog.CallerFieldName ` as key name
360+
`WithCallerSkipFrameCount` adds `caller` to `logger`'s Context. `CallerWithSkipFrameCount` is a method of zerolog's Context structure. It is used to add the caller's file name and line number in the log record, and uses `zerolog.CallerFieldName` as key name
360361

361362
This method accepts a `skipFrameCount` parameter, which specifies the number of stack frames to skip to determine the correct caller location. If the `skipFrameCount` parameter is set to -1, the global `CallerSkipFrameCount` value is used
362363

content/en/docs/hertz/tutorials/framework-exten/response_writer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ Effect display:
7676

7777
Open the interface in the example at localhost:8888, and then use the following command to observe the effect:
7878

79-
```bash
79+
```bash
8080
curl -N --location localhost:8888/flush/chunk
8181
```

content/en/docs/hertz/tutorials/toolkit/command.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ OPTIONS:
169169

170170
<!---->
171171

172-
- rm_tag value: Remove the specified tag
172+
- rm_tag value: Remove the specified tag
173173

174174
<!---->
175175

@@ -308,7 +308,7 @@ OPTIONS:
308308

309309
<!---->
310310

311-
- rm_tag value: Remove the specified tag
311+
- rm_tag value: Remove the specified tag
312312

313313
<!---->
314314

@@ -410,7 +410,7 @@ OPTIONS:
410410

411411
<!---->
412412

413-
- rm_tag value: Remove the specified tag
413+
- rm_tag value: Remove the specified tag
414414

415415
<!---->
416416

@@ -521,7 +521,7 @@ OPTIONS:
521521

522522
<!---->
523523

524-
- rm_tag value: Remove the specified tag
524+
- rm_tag value: Remove the specified tag
525525

526526
<!---->
527527

content/en/docs/hertz/tutorials/toolkit/usage-protobuf.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ description: "hz usage(protobuf)."
1212

1313
1. Create the protobuf IDL file in the current directory
1414

15-
1. Create api.proto
15+
1. Create api.proto
1616

1717
api.proto is an annotation file provided by hz, with the following content. Please import the file in the annotated proto file.
18-
18+
1919
If you want to expand the use of annotations on your own, please do not use "5" as the beginning of the sequence number to avoid conflicts. For example, "optional string xxx = 77777;".
2020

2121
```protobuf
@@ -123,7 +123,7 @@ description: "hz usage(protobuf)."
123123
}
124124
}
125125
```
126-
126+
127127
2. Create a new project
128128
129129
{{< tabs "Execute outside GOPATH" "Execute under GOPATH">}}
@@ -255,7 +255,9 @@ description: "hz usage(protobuf)."
255255
```bash
256256
hz update -I idl -idl idl/hello/hello.proto
257257
```
258+
258259
**Note**.
260+
259261
- If the dependency of the IDL is not in the same path as the main IDL, you need to add the `-I` option, which means the path to search for the IDL, equivalent to the `-I` command of protoc.
260262
- When writing update command, you need to specify not only the IDL file that defines `service`, but also all the dependency files, because protobuf's dependency files will not be updated automatically.
261263

content/en/docs/hertz/tutorials/toolkit/usage-thrift.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ description: "hz usage(thrift)."
158158
hz update -idl idl/hello.thrift
159159
```
160160

161-
**Note**:
161+
**Note**:
162+
162163
1. When writing the update command, you only need to specify the IDL file that defines the `service`. hz will automatically generate all the dependencies for that file.
163164

164165
3. As you can see

content/zh/docs/hertz/reference/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ func main() {
101101
| WithResponseBodyStream | bool | 设置是否使用流式处理,默认关闭 |
102102
| WithDialFunc | client.DialFunc | 设置 Dial Function |
103103
| WithWriteTimeout | time.Duration | 写入数据超时时间,默认值:无限长 |
104-
| WithHostClientConfigHook | func(hc interface{}) error | 设置 hook 函数来重新配置 host client,传入的 func 需要将参数 hc 断言为需要的结构体,比如 http1.HostClient ,再进行具体处理 |
104+
| WithHostClientConfigHook | func(hc interface{}) error | 设置 hook 函数来重新配置 host client,传入的 func 需要将参数 hc 断言为需要的结构体,比如 http1.HostClient,再进行具体处理 |

0 commit comments

Comments
 (0)