response

package
v0.0.0-...-f261bde Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PrettyRender bool `mapstructure:"prettyRender"`
}

type Default

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

Default is used to write the response into an http.ResponseWriter and log the error.

func New

func New(render *render.Render) *Default

New return a new Default.

func (*Default) WriteJSON

func (t *Default) WriteJSON(w http.ResponseWriter, r *http.Request, statusCode int, res any)

Write the given res as a json body and statusCode.

func (*Default) WriteJSONError

func (t *Default) WriteJSONError(w http.ResponseWriter, r *http.Request, err error)

WriteJSONError write the given error into the ResponseWriter.

type MockWriter

type MockWriter struct {
	mock.Mock
}

MockWriter is an autogenerated mock type for the Writer type

func NewMockWriter

func NewMockWriter(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockWriter

NewMockWriter creates a new instance of MockWriter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockWriter) WriteJSON

func (_m *MockWriter) WriteJSON(w http.ResponseWriter, r *http.Request, statusCode int, res interface{})

WriteJSON provides a mock function with given fields: w, r, statusCode, res

func (*MockWriter) WriteJSONError

func (_m *MockWriter) WriteJSONError(w http.ResponseWriter, r *http.Request, err error)

WriteJSONError provides a mock function with given fields: w, r, err

type Writer

type Writer interface {
	WriteJSON(w http.ResponseWriter, r *http.Request, statusCode int, res any)
	WriteJSONError(w http.ResponseWriter, r *http.Request, err error)
}

func Init

func Init(cfg Config) Writer

Jump to

Keyboard shortcuts

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