自定义响应

通过使用定制的序列化引擎(参见下一章)或使用 Iriis ,您可以轻松地编写自定义响应,直接上下文。

例如,可以定义一个处理函数,以通过处理程序返回自定义内容类型和内容,:

iris.Get("/testing", func(ctx *iris.Context) {
 ctx.SetContentType("text/plain")
 ctx.SetBody("something special in the body")
})

results matching ""

    No results matching ""