response

package
v0.0.0-...-12a582f Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

type Basic struct {
	Message string       `json:"message,omitempty"`
	Data    ResponseData `json:"data,omitempty"`
}

Basic represents a general response type, which can be empty, hold just a message, or a message and a list of message strings containing more information

type Error

type Error struct {
	Message string

	Info []string
}

type Meta

type Meta struct {
	Version string `json:"version,omitempty"`
	Token   string `json:"token,omitempty"`
}

type Response

type Response struct {
	Writer http.ResponseWriter `json:"-"`
	Data   interface{}         `json:"data"`

	Error *Error `json:"error,omitempty"`
	Meta  Meta   `json:"meta"`
}

func NewResponder

func NewResponder(w http.ResponseWriter) Response

func (*Response) AddError

func (r *Response) AddError(err Error) *Response

func (*Response) BadRequest

func (r *Response) BadRequest()

func (*Response) BadRequestWithError

func (r *Response) BadRequestWithError(err error)

func (*Response) Empty

func (r *Response) Empty()

func (*Response) ForbiddenWithError

func (r *Response) ForbiddenWithError(err error)

func (*Response) NoContent

func (r *Response) NoContent()

func (*Response) NoContentWithError

func (r *Response) NoContentWithError(err error)

func (*Response) NotFound

func (r *Response) NotFound()

func (*Response) Success

func (r *Response) Success()

func (*Response) Unauthorized

func (r *Response) Unauthorized()

func (*Response) UnexpectedError

func (r *Response) UnexpectedError()

func (*Response) UnexpectedWithError

func (r *Response) UnexpectedWithError(err error)

func (*Response) WithHeader

func (r *Response) WithHeader(header int)

type ResponseData

type ResponseData map[string]interface{}

type Status

type Status struct {
	Additional string `json:"additional,omitempty"`
	Message    string `json:"message"`
}

type TimeStartKey

type TimeStartKey struct{}

Jump to

Keyboard shortcuts

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