jsend

package module
v0.0.0-...-d9e908f Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: MIT Imports: 5 Imported by: 1

README

jsend

GO implementation of JSend

Documentation

Index

Constants

View Source
const (
	StatusSuccess = "success"
	StatusFail    = "fail"
	StatusError   = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JSend

type JSend struct {
	Status  string      `json:"status"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"message,omitempty"`
	Code    int         `json:"code,omitempty"`
}

func Error

func Error(message string) *JSend

func ErrorCode

func ErrorCode(message string, code int) *JSend

func ErrorCodeWithData

func ErrorCodeWithData(message string, code int, data interface{}) *JSend

func ErrorData

func ErrorData(message string, data interface{}) *JSend

func Fail

func Fail(data interface{}) *JSend

func Read

func Read(r io.Reader) (*JSend, error)

func Receive

func Receive(r *http.Response) (*JSend, error)

func Success

func Success(data interface{}) *JSend

func (*JSend) IsValid

func (jsend *JSend) IsValid() bool

func (*JSend) Send

func (jsend *JSend) Send(w http.ResponseWriter) error

func (*JSend) SendFormatted

func (jsend *JSend) SendFormatted(w http.ResponseWriter) error

func (*JSend) Write

func (jsend *JSend) Write(w io.Writer) error

func (*JSend) WriteFormatted

func (jsend *JSend) WriteFormatted(w io.Writer) error

Jump to

Keyboard shortcuts

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