1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00
Former-commit-id: 6c03439d21175f120c37a7d8dd067a0d10de837a
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-08-15 10:39:38 +03:00
parent e0af8ab29a
commit c9e9a4b3bc
4 changed files with 154 additions and 12 deletions

View File

@@ -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{} { [...] }
})
}