JSONP marshals the given "v" value to JSON and sends the response to the client. It reports any JSON parser or write errors back to the caller. Look the Application.SetContextErrorHandler to override the default status code 500 with a custom error response.
(v interface{}, opts ...JSONP)
| 4407 | // Look the Application.SetContextErrorHandler to override the |
| 4408 | // default status code 500 with a custom error response. |
| 4409 | func (ctx *Context) JSONP(v interface{}, opts ...JSONP) (err error) { |
| 4410 | var options *JSONP |
| 4411 | if len(opts) > 0 { |
| 4412 | options = &opts[0] |
| 4413 | } else { |
| 4414 | options = &DefaultJSONPOptions |
| 4415 | } |
| 4416 | |
| 4417 | ctx.ContentType(ContentJavascriptHeaderValue) |
| 4418 | if err = WriteJSONP(ctx, v, options); err != nil { |
| 4419 | if !options.OmitErrorHandler { |
| 4420 | ctx.handleContextError(err) |
| 4421 | } |
| 4422 | } |
| 4423 | |
| 4424 | return |
| 4425 | } |
| 4426 | |
| 4427 | type xmlMapEntry struct { |
| 4428 | XMLName xml.Name |
no test coverage detected