(ctx iris.Context)
| 59 | } |
| 60 | |
| 61 | func problemExample(ctx iris.Context) { |
| 62 | /* |
| 63 | p := iris.NewProblem(). |
| 64 | Type("/validation-error"). |
| 65 | Title("Your request parameters didn't validate"). |
| 66 | Detail("Optional details about the error."). |
| 67 | Status(iris.StatusBadRequest). |
| 68 | Key("customField1", customValue1) |
| 69 | Key("customField2", customValue2) |
| 70 | ctx.Problem(p) |
| 71 | |
| 72 | // OR |
| 73 | ctx.Problem(iris.Problem{ |
| 74 | "type": "/validation-error", |
| 75 | "title": "Your request parameters didn't validate", |
| 76 | "detail": "Optional details about the error.", |
| 77 | "status": iris.StatusBadRequest, |
| 78 | "customField1": customValue1, |
| 79 | "customField2": customValue2, |
| 80 | }) |
| 81 | |
| 82 | // OR |
| 83 | */ |
| 84 | |
| 85 | // Response like JSON but with indent of " " and |
| 86 | // content type of "application/problem+json" |
| 87 | ctx.Problem(newProductProblem("product name", "problem error details"), iris.ProblemOptions{ |
| 88 | // Optional JSON renderer settings. |
| 89 | JSON: iris.JSON{ |
| 90 | Indent: " ", |
| 91 | }, |
| 92 | // OR |
| 93 | // Render as XML: |
| 94 | // |
| 95 | // RenderXML: true, |
| 96 | // XML: iris.XML{Indent: " "}, |
| 97 | // and ctx.StatusCode(200) to see the result on browser as a user. |
| 98 | // |
| 99 | // The below `RetryAfter` field sets the "Retry-After" response header. |
| 100 | // |
| 101 | // Can accept: |
| 102 | // time.Time for HTTP-Date, |
| 103 | // time.Duration, int64, float64, int for seconds |
| 104 | // or string for date or duration. |
| 105 | // Examples: |
| 106 | // time.Now().Add(5 * time.Minute), |
| 107 | // 300 * time.Second, |
| 108 | // "5m", |
| 109 | // |
| 110 | RetryAfter: 300, |
| 111 | // A function that, if specified, can dynamically set |
| 112 | // retry-after based on the request. Useful for ProblemOptions reusability. |
| 113 | // Overrides the RetryAfter field. |
| 114 | // |
| 115 | // RetryAfterFunc: func(iris.Context) interface{} { [...] } |
| 116 | }) |
| 117 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…