mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
doc the optional ProblemOptions
parent
4986785b66
commit
41cb5a9180
|
@ -65,7 +65,31 @@ func newProductProblem(productName, detail string) iris.Problem {
|
||||||
}
|
}
|
||||||
|
|
||||||
func fireProblem(ctx iris.Context) {
|
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{} { [...] }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user