response

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgResourceNotFound is associated with `404` response code.
	MsgResourceNotFound = "The resource was not found."
	// MsgInternalServer is associated with `500` response code.
	MsgInternalServer = "An internal server error occurred."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Operation string            `json:"operation,omitempty"`
	Message   string            `json:"message,omitempty"`
	Errors    map[string]string `json:"errors,omitempty"`
}

func NewError

func NewError() *Error

NewError returns `*Error` instance.

func (Error) Write

func (e Error) Write(w http.ResponseWriter, code int, headers map[string]string)

Write calls `write` function to write error response.

type Success

type Success struct {
	Operation string      `json:"operation,omitempty"`
	Data      interface{} `json:"data,omitempty"`
	Meta      interface{} `json:"meta,omitempty"`
}

func NewSuccess

func NewSuccess() *Success

NewSuccess returns `*Success` instance.

func (Success) Write

func (s Success) Write(w http.ResponseWriter, code int, headers map[string]string)

Write calls `write` function to write success response.

Jump to

Keyboard shortcuts

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