-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from go-resty/docs-part9
Docs part9
- Loading branch information
Showing
12 changed files
with
170 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
|
||
# Debug Log | ||
|
||
The debug log provides insights into Resty's request and response details for troubleshooting. The v3 introduces the debug log formatter feature, allowing the debug log content customization for the user's use case. Out of the box, the following formatters are available: | ||
|
||
* [DebugLogFormatter]({{% godoc v3 %}}DebugLogFormatter) (default) | ||
* [DebugLogJSONFormatter]({{% godoc v3 %}}DebugLogJSONFormatter) | ||
|
||
## Default Behaviour | ||
|
||
* Automatically sanitize HTTP headers in both Request and Response if the header key contains `authorization`, `auth`, or `token`. | ||
* Applies a human-readable debug log formatter. | ||
|
||
## Examples | ||
|
||
### Get Started | ||
|
||
```go | ||
// enabling debug for all requests | ||
c := resty.New(). | ||
SetDebug(true) | ||
|
||
// enabling debug for a particular request | ||
req := c.R().SetDebug(true) | ||
|
||
// few syntactic sugar methods available; see Methods section | ||
``` | ||
|
||
### Editing Log Details | ||
|
||
Register to debug log callback for any log modification; see [DebugLog]({{% godoc v3 %}}DebugLog). | ||
|
||
```go | ||
c := resty.New(). | ||
OnDebugLog(func(dl *DebugLog) { | ||
// logic goes here | ||
}) | ||
``` | ||
|
||
### JSON Formatter | ||
|
||
```go | ||
c := resty.New(). | ||
SetDebugLogFormatter(resty.DebugLogJSONFormatter) | ||
``` | ||
|
||
### Custom Formatter | ||
|
||
See [DebugLog]({{% godoc v3 %}}DebugLog). | ||
|
||
```go | ||
// implement custom debug log formatter | ||
func DebugLogCustomFormatter(dl *DebugLog) string { | ||
logContent := "" | ||
|
||
// perform log manipulation logic here | ||
|
||
return logContent | ||
} | ||
|
||
// set the custom debug log formatter | ||
c := resty.New(). | ||
SetDebugLogFormatter(DebugLogCustomFormatter) | ||
``` | ||
|
||
## Methods | ||
|
||
### Client | ||
|
||
* [Client.SetDebug]({{% godoc v3 %}}Client.SetDebug) | ||
* [Client.EnableDebug]({{% godoc v3 %}}Client.EnableDebug) | ||
* [Client.DisableDebug]({{% godoc v3 %}}Client.DisableDebug) | ||
* [Client.SetDebugBodyLimit]({{% godoc v3 %}}Client.SetDebugBodyLimit) | ||
* [Client.OnDebugLog]({{% godoc v3 %}}Client.OnDebugLog) | ||
* [Client.SetDebugLogFormatter]({{% godoc v3 %}}Client.SetDebugLogFormatter) | ||
|
||
### Request | ||
|
||
* [Request.SetDebug]({{% godoc v3 %}}Request.SetDebug) | ||
* [Request.EnableDebug]({{% godoc v3 %}}Request.EnableDebug) | ||
* [Request.DisableDebug]({{% godoc v3 %}}Request.DisableDebug) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
title: How to do Dry-Run? | ||
--- | ||
|
||
# How to do Dry-Run? | ||
|
||
The appropriate way to do Dry-Run implementation with Resty is to implement custom transport using the `http.RoundTripper` interface. | ||
|
||
With custom transport, the user could perform any use case handling for Dry-Run. | ||
|
||
```go | ||
type DryRunTransport struct { | ||
http.RoundTripper | ||
} | ||
|
||
func (dr *DryRunTransport) RoundTrip(r *http.Request) (*http.Response, error) { | ||
// implement Dry-Run logic here ... | ||
|
||
return resp, err | ||
} | ||
|
||
c := resty.New(). | ||
SetTransport(&DryRunTransport{ | ||
// initialize dry-run fields | ||
}) | ||
|
||
defer c.Close() | ||
|
||
// start using the Resty client with dry-run ... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div class="global-msg global-msg-warning" align="center"> | ||
<p><strong>NOTE: Currently, Resty v3 is in alpha release, and documentation is in-progress ...</strong></p> | ||
<p><strong>NOTE: Currently, Resty v3 is in beta release</strong></p> | ||
</div> |