http

package
v0.0.0-...-15a7b9f Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EXCEPTION_EXIT = "exit"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	*http.Request
	// contains filtered or unexported fields
}

Request struct

func (*Request) Get

func (r *Request) Get(key string, def ...interface{}) interface{}

Get get query param by key.

func (*Request) GetBody

func (r *Request) GetBody() []byte

GetBody retrieves and returns request body content as bytes.

func (*Request) GetQuery

func (r *Request) GetQuery() map[string]interface{}

func (*Request) GetString

func (r *Request) GetString(key string, def ...interface{}) string

func (*Request) GetURL

func (r *Request) GetURL() string

GetURL returns current URL of this request.

type Response

type Response struct {
	*ResponseWriter
	Writer *ResponseWriter
}

Response

func GetResponse

func GetResponse(w http.ResponseWriter) *Response

GetResponse

func (*Response) ClearBuffer

func (r *Response) ClearBuffer()

ClearBuffer clears the response buffer.

func (*Response) Output

func (r *Response) Output()

Output outputs the buffer content to the client and clears the buffer.

func (*Response) Write

func (r *Response) Write(content ...interface{})

Write writes <content> to the response buffer.

func (*Response) WriteStatus

func (r *Response) WriteStatus(status int, content ...interface{})

Note that do not set Content-Type header here.

func (*Response) WriteStatusExit

func (r *Response) WriteStatusExit(status int, content ...interface{})

func (*Response) WriteXml

func (r *Response) WriteXml(content interface{}, rootTag ...string) error

WriteXml writes <content> to the response with XML format.

type ResponseData

type ResponseData struct {
	*gjson.Json
}

ResponseData 针对微信接口返回json格式数据设置,errcode errmsg

func (*ResponseData) HaveError

func (r *ResponseData) HaveError() bool

Ok 当返回errcode=0, errmsg="ok" 时为true errcode != 0 时为false

type ResponseWriter

type ResponseWriter struct {
	Status int // HTTP status.
	// contains filtered or unexported fields
}

ResponseWriter is the custom writer for http response.

func (*ResponseWriter) Flush

func (w *ResponseWriter) Flush()

OutputBuffer outputs the buffer to client and clears the buffer.

func (*ResponseWriter) Header

func (w *ResponseWriter) Header() http.Header

Header implements the interface function of http.ResponseWriter.Header.

func (*ResponseWriter) Hijack

func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack implements the interface function of http.Hijacker.Hijack.

func (*ResponseWriter) RawWriter

func (w *ResponseWriter) RawWriter() http.ResponseWriter

RawWriter returns the underlying ResponseWriter.

func (*ResponseWriter) Write

func (w *ResponseWriter) Write(data []byte) (int, error)

Write implements the interface function of http.ResponseWriter.Write.

func (*ResponseWriter) WriteHeader

func (w *ResponseWriter) WriteHeader(status int)

WriteHeader implements the interface of http.ResponseWriter.WriteHeader.

Jump to

Keyboard shortcuts

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