httpx

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(requestUrl string) client

noinspection GoExportedFuncWithUnexportedType

func MaxBodySize added in v1.0.1

func MaxBodySize(args ...interface{}) int64

func NewAccessTokenExpiredHandler added in v1.0.3

func NewAccessTokenExpiredHandler() *accessTokenExpiredHandler

func NewAccessTokenInvalidHandler added in v1.0.3

func NewAccessTokenInvalidHandler() *accessTokenInvalidHandler

func NewDataValidateMiddleware added in v1.0.3

func NewDataValidateMiddleware() *dataValidateMiddleware

func NewDbExceptionHandler added in v1.0.3

func NewDbExceptionHandler() *dbExceptionHandler

func NewExecuteTimeLogMiddleware added in v1.0.3

func NewExecuteTimeLogMiddleware() *executeTimeLogMiddleware

func NewFilePart

func NewFilePart(formFieldName, clientFileName, fpath string) filePart

noinspection GoExportedFuncWithUnexportedType

func NewFilePartFromBuffer

func NewFilePartFromBuffer(formFieldName, clientFileName string, buf []byte) filePart

noinspection GoExportedFuncWithUnexportedType

func NewHttpErrorHandler added in v1.0.3

func NewHttpErrorHandler() *httpErrorHandler

func NewJwtAuthMiddleware added in v1.0.3

func NewJwtAuthMiddleware(settings *securityx.JwtSettings) *jwtAuthMiddleware

func NewNormalPart

func NewNormalPart(data map[string]string) normalPart

noinspection GoExportedFuncWithUnexportedType

func NewRateLimitMiddleware added in v1.0.3

func NewRateLimitMiddleware(settings map[string]interface{}) *rateLimitMiddleware

func NewRequestLogMiddleware added in v1.0.3

func NewRequestLogMiddleware() *requestLogMiddleware

func NewRequireAccessTokenHandler added in v1.0.3

func NewRequireAccessTokenHandler() *requireAccessTokenHandler

func NewUnkownErrorHandler added in v1.0.3

func NewUnkownErrorHandler() *unkownErrorHandler

func NewValidateExceptionHandler added in v1.0.3

func NewValidateExceptionHandler() *validateExceptionHandler

func WithJwtAuthExceptionHandler added in v1.0.2

func WithJwtAuthExceptionHandler(handler ExceptionHandler)

func WithMaxBodySize added in v1.0.1

func WithMaxBodySize(arg0 interface{})

func WithValidateExceptionHandler added in v1.0.2

func WithValidateExceptionHandler(handler ExceptionHandler)

Types

type ActionFunc

type ActionFunc func(req *Request, resp *Response) (ResponsePayload, error)

type AttachmentResponse added in v1.0.3

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

func NewAttachmentResponseFromBuffer added in v1.0.3

func NewAttachmentResponseFromBuffer(buf []byte, attachmentFileName string, mimeType ...string) AttachmentResponse

func NewAttachmentResponseFromFile added in v1.0.3

func NewAttachmentResponseFromFile(fpath, attachmentFileName string, mimeType ...string) AttachmentResponse

func (AttachmentResponse) AttachmentFileName added in v1.0.3

func (p AttachmentResponse) AttachmentFileName() string

func (AttachmentResponse) Buffer added in v1.0.3

func (p AttachmentResponse) Buffer() []byte

func (AttachmentResponse) GetContentType added in v1.0.3

func (p AttachmentResponse) GetContentType() string

func (AttachmentResponse) GetContents added in v1.0.3

func (p AttachmentResponse) GetContents() interface{}

type ExceptionHandler

type ExceptionHandler interface {
	GetExceptionName() string
	MatchException(err error) bool
	HandleException(err error) ResponsePayload
}

type HandlerEntry

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

func NewHandlerEntry

func NewHandlerEntry(routeRule *mvc.RouteRule) *HandlerEntry

func (*HandlerEntry) GetRouteRule

func (e *HandlerEntry) GetRouteRule() *mvc.RouteRule

func (*HandlerEntry) HandleRequest

func (e *HandlerEntry) HandleRequest(req *Request, resp *Response)

func (*HandlerEntry) WithActionFunc

func (e *HandlerEntry) WithActionFunc(fn ActionFunc) *HandlerEntry

type HandlerModule

type HandlerModule interface {
	GetHandlerEntries() []*HandlerEntry
}

type HtmlResponse added in v1.0.3

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

func NewHtmlResponse added in v1.0.3

func NewHtmlResponse(contents string) HtmlResponse

func (HtmlResponse) GetContentType added in v1.0.3

func (p HtmlResponse) GetContentType() string

func (HtmlResponse) GetContents added in v1.0.3

func (p HtmlResponse) GetContents() interface{}

type HttpError added in v1.0.3

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

func NewHttpError added in v1.0.3

func NewHttpError(statusCode int) HttpError

func (HttpError) GetContentType added in v1.0.3

func (p HttpError) GetContentType() string

func (HttpError) GetContents added in v1.0.3

func (p HttpError) GetContents() interface{}

func (HttpError) GetStatusCode added in v1.0.3

func (p HttpError) GetStatusCode() int

type ImageResponse added in v1.0.3

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

func NewImageResponseFromBuffer added in v1.0.3

func NewImageResponseFromBuffer(buf []byte, mimeType ...string) ImageResponse

func NewImageResponseFromFile added in v1.0.3

func NewImageResponseFromFile(fpath string, mimeType ...string) ImageResponse

func (ImageResponse) Buffer added in v1.0.3

func (p ImageResponse) Buffer() []byte

func (ImageResponse) GetContentType added in v1.0.3

func (p ImageResponse) GetContentType() string

func (ImageResponse) GetContents added in v1.0.3

func (p ImageResponse) GetContents() interface{}

type JsonResponse added in v1.0.3

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

func NewJsonResponse added in v1.0.3

func NewJsonResponse(payload interface{}) JsonResponse

func (JsonResponse) GetContentType added in v1.0.3

func (p JsonResponse) GetContentType() string

func (JsonResponse) GetContents added in v1.0.3

func (p JsonResponse) GetContents() interface{}

type Middleware

type Middleware interface {
	GetName() string
	GetType() int
	GetOrder() int
	PreHandle(request *Request, response *Response)
	PostHandle(request *Request, response *Response)
}

type Request

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

func NewRequest

func NewRequest(req *http.Request) *Request

func (*Request) GetBool

func (r *Request) GetBool(name string, defaultValue ...bool) bool

func (*Request) GetClientIp

func (r *Request) GetClientIp() string

func (*Request) GetExecStart

func (r *Request) GetExecStart() time.Time

func (*Request) GetFloat32

func (r *Request) GetFloat32(name string, defaultValue ...float32) float32

func (*Request) GetFloat64

func (r *Request) GetFloat64(name string, defaultValue ...float64) float64

func (*Request) GetHeader

func (r *Request) GetHeader(headerName string) string

func (*Request) GetHeaders

func (r *Request) GetHeaders() map[string]string

func (*Request) GetInt

func (r *Request) GetInt(name string, defaultValue ...int) int

func (*Request) GetInt64

func (r *Request) GetInt64(name string, defaultValue ...int64) int64

func (*Request) GetJwt

func (r *Request) GetJwt(token ...string) *jwt.Token

func (*Request) GetMap

func (r *Request) GetMap(rules ...[]string) map[string]interface{}

func (*Request) GetMethod

func (r *Request) GetMethod() string

func (*Request) GetMiddlewares

func (r *Request) GetMiddlewares() []Middleware

func (*Request) GetQueryString

func (r *Request) GetQueryString(urlencode ...bool) string

func (*Request) GetRawBody

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

func (*Request) GetRequestUrl

func (r *Request) GetRequestUrl(withQueryString ...bool) string

func (*Request) GetRouteRule

func (r *Request) GetRouteRule() *mvc.RouteRule

func (*Request) GetString

func (r *Request) GetString(name string, defaultValue ...string) string

func (*Request) GetUploadedFile

func (r *Request) GetUploadedFile(formFieldName string) *multipart.FileHeader

func (*Request) JwtClaimBool

func (r *Request) JwtClaimBool(name string, defaultValue ...bool) bool

func (*Request) JwtClaimFloat32

func (r *Request) JwtClaimFloat32(name string, defaultValue ...float32) float32

func (*Request) JwtClaimFloat64

func (r *Request) JwtClaimFloat64(name string, defaultValue ...float64) float64

func (*Request) JwtClaimInt

func (r *Request) JwtClaimInt(name string, defaultValue ...int) int

func (*Request) JwtClaimInt64

func (r *Request) JwtClaimInt64(name string, defaultValue ...int64) int64

func (*Request) JwtClaimIntSlice

func (r *Request) JwtClaimIntSlice(name string) []int

func (*Request) JwtClaimString

func (r *Request) JwtClaimString(name string, defaultValue ...string) string

func (*Request) JwtClaimStringSlice

func (r *Request) JwtClaimStringSlice(name string) []string

func (*Request) Next

func (r *Request) Next(flag ...bool) bool

func (*Request) PathVariable

func (r *Request) PathVariable(name string, defaultValue ...string) string

func (*Request) PathVariableBool

func (r *Request) PathVariableBool(name string, defaultValue ...bool) bool

func (*Request) PathVariableFloat32

func (r *Request) PathVariableFloat32(name string, defaultValue ...float32) float32

func (*Request) PathVariableFloat64

func (r *Request) PathVariableFloat64(name string, defaultValue ...float64) float64

func (*Request) PathVariableInt

func (r *Request) PathVariableInt(name string, defaultValue ...int) int

func (*Request) PathVariableInt64

func (r *Request) PathVariableInt64(name string, defaultValue ...int64) int64

func (*Request) WithJwtPublicKeyPemFile added in v1.0.1

func (r *Request) WithJwtPublicKeyPemFile(fpath string) *Request

func (*Request) WithMiddleware

func (r *Request) WithMiddleware(m Middleware) *Request

func (*Request) WithMiddlewares

func (r *Request) WithMiddlewares(entries []Middleware) *Request

func (*Request) WithPathVariables

func (r *Request) WithPathVariables(map1 map[string]string) *Request

func (*Request) WithRouteRule

func (r *Request) WithRouteRule(rr *mvc.RouteRule) *Request

type Response

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

func NewResponse

func NewResponse(request *Request, out http.ResponseWriter) *Response

func (*Response) HasError

func (resp *Response) HasError() bool

func (*Response) NeedCorsSupport added in v1.0.2

func (resp *Response) NeedCorsSupport() bool

func (*Response) Send

func (resp *Response) Send()

func (*Response) WithCorsSettings

func (resp *Response) WithCorsSettings(corsSettings *securityx.CorsSettings) *Response

func (*Response) WithError

func (resp *Response) WithError(err error) *Response

func (*Response) WithExceptionHandler added in v1.0.1

func (resp *Response) WithExceptionHandler(handler ExceptionHandler) *Response

func (*Response) WithExceptionHandlers

func (resp *Response) WithExceptionHandlers(handlers []ExceptionHandler) *Response

func (*Response) WithExtraHeader

func (resp *Response) WithExtraHeader(headerName, headerValue string) *Response

func (*Response) WithExtraHeaders

func (resp *Response) WithExtraHeaders(headers map[string]string) *Response

func (*Response) WithPayload

func (resp *Response) WithPayload(payload ResponsePayload) *Response

type ResponsePayload

type ResponsePayload interface {
	GetContentType() string
	GetContents() interface{}
}

type XmlResponse added in v1.0.3

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

func NewXmlResponse added in v1.0.3

func NewXmlResponse(contents string) XmlResponse

func (XmlResponse) GetContentType added in v1.0.3

func (p XmlResponse) GetContentType() string

func (XmlResponse) GetContents added in v1.0.3

func (p XmlResponse) GetContents() interface{}

Jump to

Keyboard shortcuts

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