response

package
v0.0.0-...-415d151 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTetapTenangTetapSemangat = CustomError{
		Message:  "Tetap Tenang Tetap Semangat",
		Code:     999,
		HTTPCode: http.StatusInternalServerError,
	}
)

Functions

func Write

func Write(w http.ResponseWriter, result interface{})

func WriteJson

func WriteJson(w http.ResponseWriter, result interface{}, status int)

Types

type CustomError

type CustomError struct {
	Message  string
	Field    string
	Code     int
	HTTPCode int
}

func (CustomError) Error

func (c CustomError) Error() string

type ErrorBody

type ErrorBody struct {
	Errors []ErrorInfo `json:"errors"`
	Meta   interface{} `json:"meta"`
}

func BuildError

func BuildError(errors []error) ErrorBody

type ErrorInfo

type ErrorInfo struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
	Field   string `json:"field,omitempty"`
}

type MetaInfo

type MetaInfo struct {
	HTTPStatus int `json:"http_status"`
}

type SuccessBody

type SuccessBody struct {
	Data interface{} `json:"data"`
	Meta interface{} `json:"meta"`
}

func BuildSuccess

func BuildSuccess(data, meta interface{}) SuccessBody

Jump to

Keyboard shortcuts

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