utils

package
v0.0.0-...-951d22a Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadWriteTimeout = 100
	TimeOutDuration  = 5 * time.Second
	IdleTimeout      = 10
)

http configuration

View Source
const TimeFormat = "2006-01-02 15:04:05"

time format

Variables

View Source
var DebugLog, _ = logger.New("[DEBUG] - ", 2, os.Stdout)
View Source
var ErrorLog, _ = logger.New("[ERROR] - ", 5, os.Stdout)

logging configuration

View Source
var ExampleJsonData = map[string]string{
	"users":    "https://jsonplaceholder.typicode.com/users",
	"todos":    "https://jsonplaceholder.typicode.com/todos",
	"photos":   "https://jsonplaceholder.typicode.com/photos",
	"albums":   "https://jsonplaceholder.typicode.com/albums",
	"comments": "https://jsonplaceholder.typicode.com/comments",
	"posts":    "https://jsonplaceholder.typicode.com/posts",
}

example api for example mocking data from https://jsonplaceholder.typicode.com/

View Source
var HttpMessage = map[string]map[string]interface{}{
	"successfully_seed_mock": {"status": http.StatusOK, "message": StatusMessage["successfully_seed_mock"]},
	"live":                   {"status": http.StatusOK, "message": StatusMessage["live"]},
	"invalid_json":           {"status": http.StatusBadRequest, "message": StatusMessage["invalid_json"]},
	"status_ok":              {"status": http.StatusOK, "message": StatusMessage["status_ok"]},
	"status_deleted":         {"status": http.StatusNoContent, "message": StatusMessage["status_deleted"]},
	"successfully_created":   {"status": http.StatusCreated, "message": StatusMessage["successfully_created"]},
	"failed_created":         {"status": http.StatusCreated, "message": StatusMessage["failed_created"]},
	"failed_updated":         {"status": http.StatusCreated, "message": StatusMessage["failed_updated"]},
	"failed_deleted":         {"status": http.StatusCreated, "message": StatusMessage["failed_deleted"]},
}
View Source
var InfoLog, _ = logger.New("[INFO] - ", 6, os.Stdout)
View Source
var StatusMessage = map[string]string{
	"successfully_seed_mock": "Successfully seed example data",
	"live":                   "Api is Live",
	"invalid_json":           "Invalid payload",
	"status_ok":              http.StatusText(http.StatusOK),
	"status_deleted":         "Successfully deleted",
	"successfully_created":   "Successfully created",
	"failed_created":         "Failed Created",
	"failed_updated":         "Failed Updated",
	"failed_deleted":         "Failed Deleted",
}

Functions

func CreateBulkResource

func CreateBulkResource(docs []*map[string]interface{}) []*map[string]interface{}

CreateBulkResource create new slice from existing resource

func DebugLogInfo

func DebugLogInfo(text string) error

SendLogError is print debug message to console

func GenerateUuid

func GenerateUuid() string

GenerateUuid is method to generate UUID as string

func RestGet

func RestGet(url string) (int, []byte, error)

RestGet is method to doing http get request

func SendLogError

func SendLogError(text string, err error) error

SendLogError is print error message to console

func SendLogInfo

func SendLogInfo(text string) error

SendLogError is print info message to console

Types

This section is empty.

Jump to

Keyboard shortcuts

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