doc the optional ProblemOptions

Gerasimos (Makis) Maropoulos 2019-08-15 10:37:43 +03:00
parent 4986785b66
commit 41cb5a9180
No known key found for this signature in database
GPG Key ID: F169457BBDA4ACF4

@ -65,7 +65,31 @@ func newProductProblem(productName, detail string) iris.Problem {
}
func fireProblem(ctx iris.Context) {
ctx.Problem(newProductProblem("product name", "problem error details"))
// Response like JSON but with indent of " " and
// content type of "application/problem+json"
ctx.Problem(newProductProblem("product name", "problem error details"), iris.ProblemOptions{
// Optional JSON renderer settings.
JSON: iris.JSON{
Indent: " ",
},
// Sets the "Retry-After" response header.
//
// Can accept:
// time.Time for HTTP-Date,
// time.Duration, int64, float64, int for seconds
// or string for date or duration.
// Examples:
// time.Now().Add(5 * time.Minute),
// 300 * time.Second,
// "5m",
//
RetryAfter: 300,
// A function that, if specified, can dynamically set
// retry-after based on the request. Useful for ProblemOptions reusability.
// Overrides the RetryAfter field.
//
// RetryAfterFunc: func(iris.Context) interface{} { [...] }
})
}
```