Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpectFailure ¶
func ExpectFailure(t *testing.T, resp *httptest.ResponseRecorder)
ExpectFailure asserts that given response is a failure response.
func ExpectSuccess ¶
func ExpectSuccess(t *testing.T, resp *httptest.ResponseRecorder)
ExpectSuccess asserts that given response is a success response.
func ResponseFailure ¶
func ResponseFailure(c *gin.Context, options ...ResponseOption)
ResponseFailure responses the request with 200 status code and a failure message.
func ResponseSuccess ¶
func ResponseSuccess(c *gin.Context, options ...ResponseOption)
ResponseSuccess responses the request with 200 status code and a success message.
Types ¶
type ResponseOption ¶
ResponseOption is the additional data to include in response.
func WithData ¶
func WithData(data interface{}) ResponseOption
WithData includes the given data to the response.
func WithError ¶
func WithError(err error) ResponseOption
WithError includes the error as a failure reason. It is usually used along with ResponseFailure. If err is nil, empty reason will be used.
func WithField ¶
func WithField(k string, v interface{}) ResponseOption
WithField includes the given field in the response.
func WithMultipleFields ¶
func WithMultipleFields(extra gin.H) ResponseOption
WithMultipleFields includes the extra data to the response.
func WithReason ¶
func WithReason(reason string) ResponseOption
WithReason includes the given reason to the response. It is intended to use for operation failed response.