cookbook

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: MIT Imports: 5 Imported by: 18

README

Cookbook

Build Status Coverage Status Go Report Card GoDoc

Utilities library for Go(Golang) development

Documentation

Index

Constants

View Source
const (
	// RequestID Incoming request id
	RequestID = "request_id"

	// Bearer
	Bearer = "Bearer"

	// XRequestID HTTP request header key X-Request-ID
	XRequestID = "X-Request-ID"
)

Variables

This section is empty.

Functions

func BoolEnv

func BoolEnv(key string) (bool, error)

BoolEnv used for get bool value from environment

func IntEnv

func IntEnv(key string) (int, error)

IntEnv used for get bool value from environment

func ParseStringToFloat64

func ParseStringToFloat64(str string, def float64) float64

ParseStringToFloat64 Parse string to float64, error return default value

func ParseStringToInt

func ParseStringToInt(str string, def int) int

ParseStringToInt Parse string to int, error return default value

func StringEnv

func StringEnv(key string) (string, error)

StringEnv used for get string value from environment

func Stringify

func Stringify(str interface{}) string

Stringify Convert interface to string, error will return string error message

Types

type JSend

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

JSend used JSend format with some modification

func ErrorResponse added in v1.7.0

func ErrorResponse(msg string, code string) JSend

ErrorResponse is used return response with JSON format if failure in server side

func FailResponse

func FailResponse(data interface{}, code string) JSend

FailResponse is used to return response with JSON format if failure from client side

func SuccessDataResponse

func SuccessDataResponse(data interface{}, meta *Meta) JSend

SuccessDataResponse used to return response JSON format if have data value

func SuccessResponse

func SuccessResponse() JSend

SuccessResponse used to return response with JSON format success

func (JSend) Stringify

func (j JSend) Stringify() string

Stringify make JSend struct to string

type Links struct {
	Next string `json:"next,omitempty"`
	Prev string `json:"prev,omitempty"`
}

Links for meta data JSON response

func NewLinks(next, prev string) *Links

NewLinks build new links struct

type Meta

type Meta struct {
	Links *Links `json:"links,omitempty"`
}

Meta data used for JSON response

func NewMeta

func NewMeta(links *Links) *Meta

NewMeta build new meta struct

Directories

Path Synopsis
negroni

Jump to

Keyboard shortcuts

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