context

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Put

func Put(c *Context)

Types

type Context

type Context struct {
	Request  *http.Request
	Response http.ResponseWriter

	RequestID  string
	StatusCode int
	RenderType string
	// contains filtered or unexported fields
}

func Get

func Get(rw http.ResponseWriter, req *http.Request) *Context

func (*Context) AddParam

func (c *Context) AddParam(name, value string)

func (*Context) Decode

func (c *Context) Decode(result any, maxBodySize int64) error

func (*Context) DecodeJSON

func (c *Context) DecodeJSON(result any, maxBodySize int64) error

func (*Context) Error

func (c *Context) Error(status int, err error) *Error

func (*Context) ErrorFromMessage

func (c *Context) ErrorFromMessage(status int, message string, kv ...any) *Error

func (*Context) ErrorWithMessage

func (c *Context) ErrorWithMessage(status int, err error, message string, kv ...any) *Error

func (*Context) Errorf

func (c *Context) Errorf(status int, format string, ps ...any) *Error

func (*Context) Param

func (c *Context) Param(name string) (string, error)

func (*Context) QueryInt

func (c *Context) QueryInt(name string, _default int) (int, error)

func (*Context) QueryString

func (c *Context) QueryString(name string, _default string) string

func (*Context) QueryTime

func (c *Context) QueryTime(name string, _default time.Time) (time.Time, error)

func (*Context) Render

func (c *Context) Render(statusCode int, data any) error

func (*Context) RenderData

func (c *Context) RenderData(statusCode int, data []byte) error

func (*Context) RenderJSON

func (c *Context) RenderJSON(statusCode int, data any) error

func (*Context) RenderStatusNoContent

func (c *Context) RenderStatusNoContent()

func (*Context) RenderStatusOK

func (c *Context) RenderStatusOK()

func (*Context) SetHeader

func (c *Context) SetHeader(key, value string)

func (*Context) SetHeaderContentType

func (c *Context) SetHeaderContentType(ct string)

func (*Context) SetHeaderWWWAuthenticate

func (c *Context) SetHeaderWWWAuthenticate()

func (*Context) WriteHeader

func (c *Context) WriteHeader(statusCode int)

type Error

type Error struct {
	Status  int
	Message string
	Data    any
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) SetData

func (e *Error) SetData(data any) *Error

Jump to

Keyboard shortcuts

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