package module
Version: v0.3.0 Latest Latest

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 12 Imported by: 0



http server

Only supply some utils now.




This section is empty.


This section is empty.


This section is empty.


type Context

type Context struct {
	W      http.ResponseWriter
	R      *http.Request
	MaxMem int64 //upload file memory size

func NewContext

func NewContext(w http.ResponseWriter, r *http.Request) *Context

func (*Context) AddHeader

func (p *Context) AddHeader(name, value string)

add header to the response.

func (*Context) DelHeader

func (p *Context) DelHeader(name string)

del response header

func (*Context) Error added in v0.2.0

func (p *Context) Error(code int)

code should be status code in http package, example: http.StatusContinue

func (*Context) Form

func (p *Context) Form() url.Values

func (*Context) FormFile added in v0.3.0

func (p *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error)

func (*Context) FormValue

func (p *Context) FormValue(name string) string

func (*Context) GetBody added in v0.1.3

func (p *Context) GetBody() ([]byte, error)

func (*Context) GetHeader added in v0.1.4

func (p *Context) GetHeader(name string) string

read header from request

func (*Context) NotFound

func (p *Context) NotFound()

func (*Context) PostForm

func (p *Context) PostForm() url.Values

func (*Context) Query added in v0.1.2

func (p *Context) Query() url.Values

func (*Context) ReadForm added in v0.1.1

func (p *Context) ReadForm(data interface{}) error

ReadForm binds the formObject with the form data it supports any kind of type, including custom structs. It will return nothing if request data are empty. The struct field tag is "form".

func (*Context) ReadHTML added in v0.3.0

func (p *Context) ReadHTML() (string, error)

func (*Context) ReadJSON added in v0.1.3

func (p *Context) ReadJSON(v interface{}) error

func (*Context) ReadQuery

func (p *Context) ReadQuery(data interface{}) error

ReadQuery binds the "ptr" with the url query string. The struct field tag is "url".

func (*Context) ReadText added in v0.3.0

func (p *Context) ReadText() (string, error)

func (*Context) ReadXML added in v0.1.3

func (p *Context) ReadXML(v interface{}) error

func (*Context) ServeFile

func (p *Context) ServeFile(name string)

func (*Context) SetHeader

func (p *Context) SetHeader(name, value string)

set header

func (*Context) UnmarshalBody added in v0.1.3

func (p *Context) UnmarshalBody(v interface{}, unmarshaler UnmarshalerFunc) error

func (*Context) UploadFile added in v0.3.0

func (p *Context) UploadFile(key string, createFile func(string) io.WriteCloser) error

func (*Context) Write

func (p *Context) Write(data []byte) (n int, err error)

func (*Context) WriteDataJSON added in v0.1.4

func (p *Context) WriteDataJSON(data []byte) error

func (*Context) WriteDataXML added in v0.1.4

func (p *Context) WriteDataXML(data []byte) error

func (*Context) WriteHTML added in v0.3.0

func (p *Context) WriteHTML(data string) error

func (*Context) WriteHeader

func (p *Context) WriteHeader(statusCode int, h http.Header)

h may be nil

func (*Context) WriteJSON

func (p *Context) WriteJSON(v interface{}) error

func (*Context) WriteString

func (p *Context) WriteString(str string) error

func (*Context) WriteText added in v0.3.0

func (p *Context) WriteText(data string) error

func (*Context) WriteXML

func (p *Context) WriteXML(v interface{}) error

type UnmarshalerFunc added in v0.1.3

type UnmarshalerFunc func(data []byte, v interface{}) error

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL