utils

package
v0.0.0-...-fd8da55 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Layout = "02.01.2006"

Functions

func GetContext

func GetContext(key string, r *http.Request) interface{}

func NewULID

func NewULID() ulid.ULID

func Render

func Render(w http.ResponseWriter, r *http.Request, e *Envelope)

func Request

func Request(method, url string, body []byte) ([]byte, error)

func TimeFromFormat

func TimeFromFormat(s string) (time.Time, error)

func TimeToFormat

func TimeToFormat(t time.Time) string

Types

type Envelope

type Envelope struct {
	Success   bool        `json:"success"`
	RequestID string      `json:"request_id"`
	Time      string      `json:"time"`
	Response  interface{} `json:"response"`
	Error     string      `json:"error,omitempty"`
	// Message        string      `json:"message,omitempty"`
	HTTPStatusCode int `json:"-"`
}

func NewEnvelope

func NewEnvelope() *Envelope

func (*Envelope) Render

func (e *Envelope) Render(w http.ResponseWriter, r *http.Request) error

func (*Envelope) SetError

func (e *Envelope) SetError(resp error) *Envelope

func (*Envelope) SetResponse

func (e *Envelope) SetResponse(resp interface{}) *Envelope

Jump to

Keyboard shortcuts

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