@@ -537,6 +537,61 @@ agent.SetResponse(resp)
537
537
ReleaseResponse(resp)
538
538
```
539
539
540
+ <details><summary>Example handling for response values</summary>
541
+
542
+ ```go title="Example handling response"
543
+ // Create a Fiber HTTP client agent
544
+ agent := fiber.Get("https:// httpbin.org/get")
545
+
546
+ // Acquire a response object to store the result
547
+ resp := fiber.AcquireResponse()
548
+ agent.SetResponse(resp)
549
+
550
+ // Perform the HTTP GET request
551
+ code, body, errs := agent.String()
552
+ if errs != nil {
553
+ // Handle any errors that occur during the request
554
+ panic (errs)
555
+ }
556
+
557
+ // Print the HTTP response code and body
558
+ fmt.Println (" Response Code:" , code)
559
+ fmt.Println (" Response Body:" , body)
560
+
561
+ // Visit and print all the headers in the response
562
+ resp.Header .VisitAll (func (key, value []byte ) {
563
+ fmt.Println (" Header" , string (key), " value" , string (value))
564
+ })
565
+
566
+ // Release the response to free up resources
567
+ fiber.ReleaseResponse (resp)
568
+ ```
569
+
570
+ Output:
571
+ ``` txt title="Output"
572
+ Response Code: 200
573
+ Response Body: {
574
+ "args": {},
575
+ "headers": {
576
+ "Host": "httpbin.org",
577
+ "User-Agent": "fiber",
578
+ "X-Amzn-Trace-Id": "Root=1-653763d0-2555d5ba3838f1e9092f9f72"
579
+ },
580
+ "origin": "83.137.191.1",
581
+ "url": "https://httpbin.org/get"
582
+ }
583
+
584
+ Header Content-Length value 226
585
+ Header Content-Type value application/json
586
+ Header Server value gunicorn/19.9.0
587
+ Header Date value Tue, 24 Oct 2023 06:27:28 GMT
588
+ Header Connection value keep-alive
589
+ Header Access-Control-Allow-Origin value *
590
+ Header Access-Control-Allow-Credentials value true
591
+ ```
592
+
593
+ </details >
594
+
540
595
### Dest
541
596
542
597
Dest sets custom dest. The contents of dest will be replaced by the response body, if the dest is too small a new slice will be allocated.
0 commit comments