Status sets HTTP error code for problem's status field. Example: 404 It is required.
(statusCode int)
| 149 | // |
| 150 | // It is required. |
| 151 | func (p Problem) Status(statusCode int) Problem { |
| 152 | shouldOverrideTitle := !p.keyExists("title") |
| 153 | |
| 154 | // if !shouldOverrideTitle { |
| 155 | // typ, found := p["type"] |
| 156 | // shouldOverrideTitle = !found || isEmptyTypeURI(typ.(string)) |
| 157 | // } |
| 158 | |
| 159 | if shouldOverrideTitle { |
| 160 | // Set title by code. |
| 161 | p.Title(http.StatusText(statusCode)) |
| 162 | } |
| 163 | |
| 164 | return p.Key("status", statusCode) |
| 165 | } |
| 166 | |
| 167 | // Detail sets the problem's detail field. |
| 168 | // Example: "Optional details about the error...". |