response

package
v0.0.0-...-b351023 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound         = &Error{Text: "Resource could not be found"}
	ErrMethodNotAllowed = &Error{Text: "Method not supported by the resource"}
	ErrParse            = &Error{Text: "Unable to process the request due to invalid syntax"}
	ErrValidation       = &Error{Text: "Unable to process the request due to invalid data"}
	ErrInternal         = &Error{Text: "The server encountered an unexpected condition"}
)

Functions

func Gob

func Gob(w http.ResponseWriter, v interface{}, code int)

func JSON

func JSON(w http.ResponseWriter, v interface{}, code int)

Types

type Error

type Error struct {
	Text    string
	Details error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) Wrap

func (e *Error) Wrap(err error) *Error

type Response

type Response struct {
	Status  string      `json:"status"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
	Details interface{} `json:"details,omitempty"`
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(w http.ResponseWriter) *Response

func Prepare

func Prepare(w http.ResponseWriter, v interface{}, code int) *Response

func (*Response) AddCookie

func (r *Response) AddCookie(c *http.Cookie)

func (*Response) Gob

func (r *Response) Gob()

func (*Response) JSON

func (r *Response) JSON()

func (*Response) SetStatusCode

func (r *Response) SetStatusCode(code int)

Jump to

Keyboard shortcuts

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