| 43 | } |
| 44 | |
| 45 | func newProductProblem(productName, detail string) iris.Problem { |
| 46 | return iris.NewProblem(). |
| 47 | // The type URI, if relative it automatically convert to absolute. |
| 48 | Type("/product-error"). |
| 49 | // The title, if empty then it gets it from the status code. |
| 50 | Title("Product validation problem"). |
| 51 | // Any optional details. |
| 52 | Detail(detail). |
| 53 | // The status error code, required. |
| 54 | Status(iris.StatusBadRequest). |
| 55 | // Any custom key-value pair. |
| 56 | Key("productName", productName) |
| 57 | // Optional cause of the problem, chain of Problems. |
| 58 | // Cause(iris.NewProblem().Type("/error").Title("cause of the problem").Status(400)) |
| 59 | } |
| 60 | |
| 61 | func problemExample(ctx iris.Context) { |
| 62 | /* |