13518219792

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

创新互联GoFrame教程:GoFrame数据返回-基本介绍

HTTP Server​的数据返回通过​ghttp.Response​对象实现,​ghttp.Response​对象实现了标准库的​http.ResponseWriter​接口。数据输出使用​Write*​相关方法实现,并且数据输出采用了​Buffer​机制,因此数据的处理效率比较高。任何时候可以通过​OutputBuffer​方法输出缓冲区数据到客户端,并清空缓冲区数据。

创新互联于2013年成立,是专业互联网技术服务公司,拥有项目成都网站建设、做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元广宗做网站,已为上家服务,为广宗各地企业和个人服务,联系电话:028-86922220

常用方法:更详细的接口列表请参考 https://pkg.GO.dev/github.com/gogf/gf/v2/net/ghttp#Response

func (r *Response) Write(content ...interface{})
func (r *Response) WriteExit(content ...interface{})
func (r *Response) WriteJson(content interface{}) error
func (r *Response) WriteJsonExit(content interface{}) error
func (r *Response) WriteJsonP(content interface{}) error
func (r *Response) WriteJsonPExit(content interface{}) error
func (r *Response) WriteOver(content ...interface{})
func (r *Response) WriteOverExit(content ...interface{})
func (r *Response) WriteStatus(status int, content ...interface{})
func (r *Response) WriteStatusExit(status int, content ...interface{})
func (r *Response) WriteTpl(tpl string, params ...gview.Params) error
func (r *Response) WriteTplContent(content string, params ...gview.Params) error
func (r *Response) WriteTplDefault(params ...gview.Params) error
func (r *Response) WriteXml(content interface{}, rootTag ...string) error
func (r *Response) WriteXmlExit(content interface{}, rootTag ...string) error
func (r *Response) Writef(format string, params ...interface{})
func (r *Response) WritefExit(format string, params ...interface{})
func (r *Response) Writefln(format string, params ...interface{})
func (r *Response) WriteflnExit(format string, params ...interface{})
func (r *Response) Writeln(content ...interface{})
func (r *Response) WritelnExit(content ...interface{})

简要说明:

此外,需要提一下,​Header​的操作可以通过标准库的方法来实现,例如:

Response.Header().Set("Content-Type", "text/plain; charset=utf-8")

分享文章:创新互联GoFrame教程:GoFrame数据返回-基本介绍
文章来源:http://cdbrznjsb.com/article/cdpsphi.html

其他资讯

让你的专属顾问为你服务