func responseMessage(resp io.Writer, ctx *jas.Context) int { if ctx.Error != nil { ctx.Status = ctx.Error.Status() } var written int jsonBytes, _ := json.Marshal(ctx.Data) if ctx.Callback != "" { // handle JSONP ctx.ResponseHeader.Set("Content-Type", "application/javascript; charset=utf-8") a, _ := resp.Write([]byte(ctx.Callback + "(")) b, _ := resp.Write(jsonBytes) c, _ := resp.Write([]byte(");")) written = a + b + c } else { written, _ = resp.Write(jsonBytes) } return written }
// Get responds on the root API handler ("/api/") with 303 SeeOther // and a link to the API documentation on the project homepage. func (*Api) Get(ctx *jas.Context) { ctx.Status = http.StatusSeeOther ctx.ResponseHeader.Set("Location", APIDocs) ctx.Data = http.StatusText(http.StatusSeeOther) + ": " + APIDocs }