JSONP serializes the given struct as JSON into the response body. It adds padding to response body to request data from a server residing in a different domain than the client. It also sets the Content-Type as "application/javascript".
(code int, obj any)
| 1192 | // It adds padding to response body to request data from a server residing in a different domain than the client. |
| 1193 | // It also sets the Content-Type as "application/javascript". |
| 1194 | func (c *Context) JSONP(code int, obj any) { |
| 1195 | callback := c.DefaultQuery("callback", "") |
| 1196 | if callback == "" { |
| 1197 | c.Render(code, render.JSON{Data: obj}) |
| 1198 | return |
| 1199 | } |
| 1200 | c.Render(code, render.JsonpJSON{Callback: callback, Data: obj}) |
| 1201 | } |
| 1202 | |
| 1203 | // JSON serializes the given struct as JSON into the response body. |
| 1204 | // It also sets the Content-Type as "application/json". |