response

package
v1.0.1006 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = New()

默认

Functions

This section is empty.

Types

type Response

type Response struct {
	// contains filtered or unexported fields
}

*

  • 响应 *
  • @create 2021-10-28
  • @author deatil

func New

func New() *Response

使用

func (*Response) Abort

func (this *Response) Abort()

错误暂停

func (*Response) AbortWithError

func (this *Response) AbortWithError(code int, err error) *router.Error

输出错误状态

func (*Response) AbortWithStatus

func (this *Response) AbortWithStatus(code int)

输出状态

func (*Response) AbortWithStatusJSON

func (this *Response) AbortWithStatusJSON(code int, jsonObj any)

输出 json 状态

func (*Response) AsciiJSON

func (this *Response) AsciiJSON(code int, obj any)

AsciiJSON

func (*Response) Data

func (this *Response) Data(code int, contentType string, data []byte)

Data

func (*Response) DataFromReader

func (this *Response) DataFromReader(
	code int,
	contentLength int64,
	contentType string,
	reader io.Reader,
	extraHeaders map[string]string,
)

DataFromReader

func (*Response) Download

func (this *Response) Download(filePath string, fileName string)

下载

func (*Response) File

func (this *Response) File(filepath string)

File

func (*Response) FileAttachment

func (this *Response) FileAttachment(filepath, filename string)

下载

func (*Response) FileFromFS

func (this *Response) FileFromFS(filepath string, fs http.FileSystem)

FileFromFS

func (*Response) Forbidden

func (this *Response) Forbidden()

禁止

func (*Response) GetContext

func (this *Response) GetContext() *router.Context

获取上下文

func (*Response) HTML

func (this *Response) HTML(code int, name string, obj any)

HTML

func (*Response) IndentedJSON

func (this *Response) IndentedJSON(code int, obj any)

IndentedJSON

func (*Response) JSON

func (this *Response) JSON(code int, obj any)

JSON

func (*Response) JSONP

func (this *Response) JSONP(code int, obj any)

JSONP

func (*Response) ProtoBuf

func (this *Response) ProtoBuf(code int, obj any)

ProtoBuf

func (*Response) PureJSON

func (this *Response) PureJSON(code int, obj any)

PureJSON

func (*Response) Redirect

func (this *Response) Redirect(code int, location string)

Redirect

func (*Response) Render

func (this *Response) Render(code int, r router.Render)

Render

func (*Response) ReturnJson

func (this *Response) ReturnJson(data any)

返回 json

func (*Response) ReturnJsonFromString

func (this *Response) ReturnJsonFromString(jsonStr string)

将json字符窜以标准json格式返回 例如,从redis读取json、格式的字符串,返回给浏览器json格式

func (*Response) ReturnString

func (this *Response) ReturnString(contents string)

返回字符

func (*Response) SSEvent

func (this *Response) SSEvent(name string, message any)

SSEvent

func (*Response) SecureJSON

func (this *Response) SecureJSON(code int, obj any)

SecureJSON

func (*Response) SetAccepted

func (this *Response) SetAccepted(formats ...string)

SetAccepted

func (*Response) SetCookie

func (this *Response) SetCookie(
	name string,
	value string,
	maxAge int,
	path string,
	domain string,
	secure bool,
	httpOnly bool,
)

设置 cookie

func (*Response) SetSameSite

func (this *Response) SetSameSite(samesite http.SameSite)

SetSameSite

func (*Response) Status

func (this *Response) Status(code int)

Status

func (*Response) Unauthorized

func (this *Response) Unauthorized()

错误

func (*Response) View added in v1.0.1006

func (this *Response) View(template string, obj any)

渲染模板

func (*Response) WithContext

func (this *Response) WithContext(ctx *router.Context) *Response

设置上下文

func (*Response) WithHeader

func (this *Response) WithHeader(key string, value string) *Response

设置 header

func (*Response) WithHeaders

func (this *Response) WithHeaders(headers map[string]string) *Response

批量设置 header

func (*Response) WithHttpCode

func (this *Response) WithHttpCode(httpCode int) *Response

设置状态码

func (*Response) XML

func (this *Response) XML(code int, obj any)

XML

func (*Response) YAML

func (this *Response) YAML(code int, obj any)

YAML

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL