Example #1
0
func OutputXML(content []byte, ctx *X.Context, args ...int) (err error) {
	code := ctx.Code
	if len(args) > 0 {
		code = args[0]
	}
	ctx.Object().XMLBlob(code, content)
	return nil
}
Example #2
0
func OutputJSON(content []byte, ctx *X.Context, args ...int) (err error) {
	callback := ctx.Query(`callback`)
	code := ctx.Code
	if len(args) > 0 {
		code = args[0]
	}
	if callback != `` {
		content = []byte(callback + "(" + string(content) + ");")
	}
	ctx.Object().JSONBlob(code, content)
	return nil
}
Example #3
0
func RenderHTML(ctx *X.Context) (b []byte, err error) {
	if ctx.Tmpl == `` {
		return
	}
	ctx.Context.SetFunc(`Status`, func() int {
		return ctx.Output.Status
	})
	ctx.Context.SetFunc(`Message`, func() interface{} {
		return ctx.Output.Message
	})
	b, err = ctx.Object().Fetch(ctx.Tmpl, ctx.Output.Data)
	return
}