httpx

package
v1.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ApplicationJson means application/json.
	ApplicationJson = "application/json"
	// ContentEncoding means Content-Encoding.
	ContentEncoding = "Content-Encoding"
	// ContentSecurity means X-Content-Security.
	ContentSecurity = "X-Content-Security"
	// ContentType means Content-Type.
	ContentType = "Content-Type"
	// KeyField means key.
	KeyField = "key"
	// SecretField means secret.
	SecretField = "secret"
	// TypeField means type.
	TypeField = "type"
	// CryptionType means cryption.
	CryptionType = 1
)
View Source
const (
	// CodeSignaturePass means signature verification passed.
	CodeSignaturePass = iota
	// CodeSignatureInvalidHeader means invalid header in signature.
	CodeSignatureInvalidHeader
	// CodeSignatureWrongTime means wrong timestamp in signature.
	CodeSignatureWrongTime
	// CodeSignatureInvalidToken means invalid token in signature.
	CodeSignatureInvalidToken
)

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, err error)

Error writes err into w.

func GetRemoteAddr added in v1.0.1

func GetRemoteAddr(r *http.Request) string

GetRemoteAddr returns the peer address, supports X-Forward-For.

func Ok

func Ok(w http.ResponseWriter)

Ok writes HTTP 200 OK into w.

func OkJson

func OkJson(w http.ResponseWriter, v interface{})

OkJson writes v into w with 200 OK.

func Parse

func Parse(r *http.Request, v interface{}) error

Parse parses the request.

func ParseForm

func ParseForm(r *http.Request, v interface{}) error

ParseForm parses the form request.

func ParseHeader

func ParseHeader(headerValue string) map[string]string

ParseHeader parses the request header and returns a map.

func ParseHeaders added in v1.1.10

func ParseHeaders(r *http.Request, v interface{}) error

ParseHeaders parses the headers request.

func ParseJsonBody

func ParseJsonBody(r *http.Request, v interface{}) error

ParseJsonBody parses the post request which contains json in body.

func ParsePath

func ParsePath(r *http.Request, v interface{}) error

ParsePath parses the symbols reside in url path. Like http://localhost/bag/:name

func SetErrorHandler added in v1.0.28

func SetErrorHandler(handler func(error) (int, interface{}))

SetErrorHandler sets the error handler, which is called on calling Error.

func WriteJson

func WriteJson(w http.ResponseWriter, code int, v interface{})

WriteJson writes v as json string into w with code.

Types

type Router

type Router interface {
	http.Handler
	Handle(method, path string, handler http.Handler) error
	SetNotFoundHandler(handler http.Handler)
	SetNotAllowedHandler(handler http.Handler)
}

Router interface represents a http router that handles http requests.

Jump to

Keyboard shortcuts

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