mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
add ProblemOptions https://github.com/kataras/iris/issues/1335#issuecomment-521546506
Former-commit-id: 6c03439d21175f120c37a7d8dd067a0d10de837a
This commit is contained in:
@@ -82,5 +82,27 @@ func problemExample(ctx iris.Context) {
|
||||
|
||||
// Response like JSON but with indent of " " and
|
||||
// content type of "application/problem+json"
|
||||
ctx.Problem(newProductProblem("product name", "problem error details"))
|
||||
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{} { [...] }
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user