http

package
v0.0.0-...-bac99df Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMinDispatchInterval = 0 * time.Millisecond
View Source
const DefaultTimeout = 60 * time.Second
View Source
const (
	SignName = "sign"
)

Variables

This section is empty.

Functions

func CollectRequestParams

func CollectRequestParams(r *http.Request) (params map[string]string)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func DefaultHandlerOption

func DefaultHandlerOption() *handlerOption

func ExecuteRequestWithJson

func ExecuteRequestWithJson(
	method string,
	url string,
	timeout time.Duration,
	token string,
	request interface{},
	response interface{},
) error

func GetJson

func GetJson(
	url string,
	timeout time.Duration,
	token string,
	request interface{},
	response interface{},
) error

func NewHandlerOption

func NewHandlerOption(optionFuncs ...HandlerOptionFunc) *handlerOption

func ParseIntRequestParam

func ParseIntRequestParam(requestParams map[string]string, requestParamName string, must bool) (requestParam int, err error)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func ParseIntSliceRequestParam

func ParseIntSliceRequestParam(requestParams map[string]string, requestParamName string, must bool) (requestParam []int, err error)

func ParseString2StringMapRequestParam

func ParseString2StringMapRequestParam(requestParams map[string]string, requestParamName string, must bool) (requestParam map[string]string, err error)

func ParseStringRequestParam

func ParseStringRequestParam(requestParams map[string]string, requestParamName string, must bool) (requestParam string, err error)

func PostJson

func PostJson(
	url string,
	timeout time.Duration,
	token string,
	request interface{},
	response interface{},
) error

Types

type ErrConvert2NumFail

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewErrConvert2NumFail

func NewErrConvert2NumFail(str string, err error) *ErrConvert2NumFail

func (ErrConvert2NumFail) Error

func (e ErrConvert2NumFail) Error() string

type ErrInvalidParam

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewErrInvalidParam

func NewErrInvalidParam(name string, value string) *ErrInvalidParam

func (ErrInvalidParam) Error

func (e ErrInvalidParam) Error() string

type ErrInvalidSign

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewErrInvalidSign

func NewErrInvalidSign(invalidSign string, validSign string) *ErrInvalidSign

func (ErrInvalidSign) Error

func (e ErrInvalidSign) Error() string

type ErrParseFormFail

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewParseFormFail

func NewParseFormFail(err error) *ErrParseFormFail

func (ErrParseFormFail) Error

func (e ErrParseFormFail) Error() string

type HandlerOptionFunc

type HandlerOptionFunc func(option *handlerOption)

func WithHandlerMinDispatchInterval

func WithHandlerMinDispatchInterval(minDispatchInterval time.Duration) HandlerOptionFunc

func WithHandlerTimeout

func WithHandlerTimeout(timeout time.Duration) HandlerOptionFunc

type InternalRequest

type InternalRequest struct {
	Pattern string
	W       http.ResponseWriter
	R       *http.Request
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

type InternalResponse

type InternalResponse struct {
	W http.ResponseWriter
	R *http.Request
}

func InternalRequestResponse

func InternalRequestResponse(pid *actor.PID, send *InternalRequest, timeout time.Duration) (*InternalResponse, error)

type Response

type Response struct {
	Sign         string `json:"sign"`
	ErrorCode    int    `json:"error_code"`
	ErrorMessage string `json:"error_msg"`
	Data         string `json:"data"`
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewResponse

func NewResponse() *Response

func (*Response) Marshal

func (resp *Response) Marshal() string

type Server

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

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewServer

func NewServer() *Server

func (*Server) Dispatch

func (s *Server) Dispatch(super mactor.ISuper, sender *actor.PID, ctx actor.Context, recv *InternalRequest)

func (*Server) Listen

func (s *Server) Listen(addr string) (err error)

func (*Server) Listener

func (s *Server) Listener() net.Listener

func (*Server) MustRegister

func (s *Server) MustRegister(super mactor.ISuper, pattern string, fn http.HandlerFunc, option *handlerOption)

func (*Server) Serve

func (s *Server) Serve()

func (*Server) ServeTLS

func (s *Server) ServeTLS(certFile string, keyFile string)

type URLRequest

type URLRequest struct {
	Sign string `json:"sign"`
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

func NewURLRequest

func NewURLRequest() *URLRequest

func (*URLRequest) UnmarshalFromRequest

func (req *URLRequest) UnmarshalFromRequest(r *http.Request, validSign string) (requestParams map[string]string, err error)

Jump to

Keyboard shortcuts

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