typrest

package
v0.8.36 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HealthStatusOK = "OK"

HealthStatusOK is health status ok

View Source
var Stdout io.Writer = os.Stdout

Stdout standard output

Functions

func CreateAndLoadDotEnv

func CreateAndLoadDotEnv(envfile string, configs []*AppCfg) error

CreateAndLoadDotEnv to create and load envfile

func HTTPError

func HTTPError(err error) *echo.HTTPError

HTTPError convert error to *echo.HTTPError

Types

type AppCfg

type AppCfg struct {
	CtorName string
	Prefix   string
	SpecType string
	Fields   []*Field
}

AppCfg model

type AppCfgAnnotation

type AppCfgAnnotation struct {
	TagName  string // By default is `@app-cfg`
	Template string // By default defined in defaultCfgTemplate variable
	Target   string // By default is `cmd/PROJECT_NAME/cfg_annotated.go`
	DotEnv   bool   // If true then create and load “.env`
}

AppCfgAnnotation handle @app-cfg annotation e.g. `@app-cfg (prefix: "PREFIX" ctor_name:"CTOR")`

func (*AppCfgAnnotation) Annotate

func (m *AppCfgAnnotation) Annotate(c *typannot.Context) error

Annotate AppCfg to prepare dependency-injection and env-file

func (*AppCfgAnnotation) CreateConfigs

func (m *AppCfgAnnotation) CreateConfigs(c *typannot.Context) []*AppCfg

CreateConfigs create configs

type AppCfgTmplData

type AppCfgTmplData struct {
	Package string
	Imports []string
	Configs []*AppCfg
}

AppCfgTmplData template

type EchoLogrus

type EchoLogrus struct {
	*logrus.Logger
	// contains filtered or unexported fields
}

EchoLogrus is implementation of echo Logger

func WrapLogrus

func WrapLogrus(logger *logrus.Logger) *EchoLogrus

WrapLogrus logrus logger in echo log interface

func (*EchoLogrus) Debugj

func (l *EchoLogrus) Debugj(j log.JSON)

Debugj debug json log

func (*EchoLogrus) Errorj

func (l *EchoLogrus) Errorj(j log.JSON)

Errorj error json log

func (*EchoLogrus) Fatalj

func (l *EchoLogrus) Fatalj(j log.JSON)

Fatalj fatal json log

func (*EchoLogrus) Infoj

func (l *EchoLogrus) Infoj(j log.JSON)

Infoj info json log

func (*EchoLogrus) Level

func (l *EchoLogrus) Level() log.Lvl

Level returns logger level

func (*EchoLogrus) Output

func (l *EchoLogrus) Output() io.Writer

Output logger output func

func (*EchoLogrus) Panicj

func (l *EchoLogrus) Panicj(j log.JSON)

Panicj panic json log

func (*EchoLogrus) Prefix

func (l *EchoLogrus) Prefix() string

Prefix of echo logrus

func (*EchoLogrus) Printj

func (l *EchoLogrus) Printj(j log.JSON)

Printj print json log

func (*EchoLogrus) SetHeader

func (l *EchoLogrus) SetHeader(string)

SetHeader to set header (NOT SUPPORTED)

func (*EchoLogrus) SetLevel

func (l *EchoLogrus) SetLevel(lvl log.Lvl)

SetLevel set level to logger from given log.Lvl

func (*EchoLogrus) SetPrefix

func (l *EchoLogrus) SetPrefix(prefix string)

SetPrefix to set prefix

func (*EchoLogrus) Warnj

func (l *EchoLogrus) Warnj(j log.JSON)

Warnj warning json log

type Error

type Error interface {
	error
	HTTPError() *echo.HTTPError
}

Error interface

func NewError

func NewError(code int, message string) Error

NewError return error

type Field

type Field struct {
	Key     string
	Default string
}

Field model

type HealthCheck

type HealthCheck map[string]func() error

HealthCheck to handle health-check

func (HealthCheck) Result

func (h HealthCheck) Result() (status int, message map[string]string)

Result of HealthCheck

type Router

type Router interface {
	SetRoute(Server) error
}

Router responsible to route

func NewRouter

func NewRouter(fn SetRouteFn) Router

NewRouter return new instance of Router

type Routers

type Routers []Router

Routers is slice of router

func (Routers) SetRoute

func (r Routers) SetRoute(server Server) error

SetRoute to server

type Server

type Server interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	Any(path string, handler echo.HandlerFunc, middleware ...echo.MiddlewareFunc) []*echo.Route
	Add(method, path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	Match(methods []string, path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) []*echo.Route
	Group(prefix string, m ...echo.MiddlewareFunc) *echo.Group
	Use(m ...echo.MiddlewareFunc)
}

Server interface for echo.Echo and echo.Group

type SetRouteFn

type SetRouteFn func(Server) error

SetRouteFn function SetRoute

type ValidErr

type ValidErr struct {
	Message string
}

ValidErr validation error

func NewValidErr

func NewValidErr(message string) *ValidErr

NewValidErr create ValidationError

func (*ValidErr) Error

func (v *ValidErr) Error() string

func (*ValidErr) HTTPError

func (v *ValidErr) HTTPError() *echo.HTTPError

HTTPError return echo HTTP Error

Jump to

Keyboard shortcuts

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