func writeJSONEncoded(ctx *app.Context, user reflect.Value) { json, err := JSONEncode(ctx, user.Interface()) if err != nil { panic(err) } ctx.SetHeader("Content-Type", "application/json") ctx.SetHeader("Content-Length", strconv.Itoa(len(json))) if _, err := ctx.Write(json); err != nil { panic(err) } }
func UserImageHandler(ctx *app.Context) { if ImageHandler != nil { ImageHandler(ctx) return } id := ctx.IndexValue(0) format := ctx.IndexValue(1) if lower := strings.ToLower(format); lower != format { ctx.MustRedirectReverse(true, ImageHandlerName, id, lower) return } ctx.SetHeader("Content-Type", "image/"+format) httpserve.NeverExpires(ctx) bs := ctx.Blobstore() if err := bs.Serve(ctx, id, nil); err != nil { panic(err) } }