Skip to content

Commit

Permalink
Update "Configuration" chapter with the DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierperez committed Oct 26, 2019
1 parent 72bad09 commit 1f376bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,22 @@ The main Chucker activity is launched in its own task, allowing it to be display

## Configure 🎨

You can customize chucker providing an instance of a `ChuckerCollector`:
You can customize Chucker by calling the DSL `configureChucker`.
It may be used to disable one of the features (HTTP or Errors).

```kotlin
// Create the Collector
val chuckerCollector = ChuckerCollector(
context = this,
// Toggles visibility of the push notification
showNotification = true,
// Allows to customize the retention period of collected data
configureChucker {
http {
enabled = true
showNotification = true
retentionPeriod = RetentionManager.Period.ONE_HOUR
)

// Create the Interceptor
val chuckerInterceptor = ChuckerInterceptor(
context = this,
// The previously created Collector
collector = chuckerCollector,
// The max body content length, after this responses will be truncated.
maxContentLength = 250000L,
// List of headers to obfuscate in the Chucker UI
headersToRedact = listOf("Auth-Token"))

// Don't forget to plug the ChuckerInterceptor inside the OkHttpClient
val client = OkHttpClient.Builder()
.addInterceptor(chuckerInterceptor)
.build()
maxContentLength = 250000L
headersToRedact = listOf("Auth-Token")
}
error {
enabled = true
}
}
```

### Throwables ☄️
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class HttpBinClient(

private val chuckerInterceptor = ChuckerInterceptor(
context = context,
collector = collector,
maxContentLength = 250000L
collector = collector
)

private val httpClient =
Expand Down

0 comments on commit 1f376bb

Please sign in to comment.