예제 #1
0
파일: user.go 프로젝트: rainycape/gondola
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)
	}
}
예제 #2
0
파일: images.go 프로젝트: rainycape/gondola
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)
	}
}