From 41cb5a9180de859e978df40eccead82bd9d2236a Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Thu, 15 Aug 2019 10:37:43 +0300 Subject: [PATCH] doc the optional ProblemOptions --- Routing-error-handlers.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Routing-error-handlers.md b/Routing-error-handlers.md index 24fba62..bae522c 100644 --- a/Routing-error-handlers.md +++ b/Routing-error-handlers.md @@ -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{} { [...] } + }) } ```