helpers

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FailOnError

func FailOnError(err error, msg string)

FailOnError Fatal error when fail

func ParseUInt

func ParseUInt(stringToParse string) (uint, error)

ParseUInt helper to avoid code repetition

func ParseUInt64

func ParseUInt64(stringToParse string) (uint64, error)

ParseUInt64 helper to avoid code repetition

func RandomString10

func RandomString10() string

RandomString10 returns a random 10 characters string

func ReadJSON

func ReadJSON(w http.ResponseWriter, r *http.Request, v interface{}) error

ReadJSON reads a json payload and unmarshal it to an interface

func ReadValidateJSON

func ReadValidateJSON(w http.ResponseWriter, r *http.Request, v interface{}) error

ReadValidateJSON reads a json payload and unmarshal it to an interface and validates it

func WriteErrorJSON

func WriteErrorJSON(w http.ResponseWriter, status int, message string)

WriteErrorJSON writes a json error

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, v interface{})

WriteJSON writes json value

Types

type StatusResponse

type StatusResponse struct {
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
}

StatusResponse is a status response model

type Validable

type Validable interface {
	Validate() error
}

Validable is an interface to implement to validate a struct while parsing it

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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