Documentation ¶
Overview ¶
Package mock contains testing utilities and mocks shared between packages.
Index ¶
- func GetHeaderParam(r *http.Request, key string) string
- func GetQueryParam(r *http.Request, key string) string
- func GetQueryParamForBool(r *http.Request, key string) (bool, error)
- func GetQueryParamForInt(r *http.Request, key string) (int64, error)
- func GetQueryParamForTime(r *http.Request, key string) (convert.JSONTime, error)
- func GetURLParam(r *http.Request, key string) string
- func GetURLParamForInt(r *http.Request, key string) int64
- func ReadCloser() *readCloser
- func ResponseWriter() *responseWriter
- func SendHTTPResponse(w http.ResponseWriter, httpStatus int, responses ...interface{})
- func SetHeaders(w http.ResponseWriter, headerMap http.Header)
- type HTTPResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetQueryParamForBool ¶ added in v0.36.0
func GetQueryParamForInt ¶ added in v0.36.0
func GetQueryParamForTime ¶ added in v0.36.0
func ReadCloser ¶ added in v0.26.0
func ReadCloser() *readCloser
ReadCloser returns a mock io.ReadCloser that can be set to return an err when Read is called on it and do nothing when Close is called on it.
func ResponseWriter ¶ added in v0.26.0
func ResponseWriter() *responseWriter
ResponseWriter returns a mock ResponseWriter implementing http.ResponseWriter.
func SendHTTPResponse ¶
func SendHTTPResponse(w http.ResponseWriter, httpStatus int, responses ...interface{})
SendHTTPResponse sends the http response to the client
func SetHeaders ¶
func SetHeaders(w http.ResponseWriter, headerMap http.Header)
SetHeaders sets the headers in response
Types ¶
type HTTPResult ¶
HTTPResult is the result return by the library
func DoHTTPRequest ¶
func DoHTTPRequest(ctx context.Context, client *http.Client, method string, urlString string, body interface{}, required []string, okResponse interface{}, errorResponse interface{}) (*HTTPResult, error)
DoHTTPRequest returns HTTPResult
func (*HTTPResult) Error ¶
func (r *HTTPResult) Error() string
Click to show internal directories.
Click to hide internal directories.