web

package
v0.0.0-...-2c24670 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 24 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultAuthedConfig default Authed middleware config.
	DefaultAuthedConfig = AuthedConfig{
		Skipper: AuthedSkipper(),
	}
)

Functions

func ApiContextMiddleWare

func ApiContextMiddleWare() func(echo.HandlerFunc) echo.HandlerFunc

func AuthedSkipper

func AuthedSkipper() func(echo.Context) bool

func AuthedWithConfig

func AuthedWithConfig(config AuthedConfig, cl AuthedContextLookup) echo.MiddlewareFunc

AuthedWithConfig ...

func Config

func Config(c ApiContext) error

func ErrorHandler

func ErrorHandler(err error, c echo.Context)

ErrorHandler handles errors

func Healthz

func Healthz(c ApiContext) error

func InitRoutes

func InitRoutes(e *echo.Echo)

func QParams

func QParams(c echo.Context, required ...string) (map[string]string, error)

Types

type ApiContext

type ApiContext interface {
	echo.Context

	Payload() *jsonapi.OnePayload
	Attrs(permitted ...string) map[string]interface{}
	AttrKeys() []string
	RequireAttrs(...string) error
	BindAndValidate(interface{}) error
	BindMulti(interface{}) ([]interface{}, error)
	BindIdParam(*int, ...string) error
	JsonApi(interface{}, int) error
	JsonApiOK(interface{}, ...interface{}) error
	JsonApiOKPaged(interface{}, *meta.Pagination, ...interface{}) error
	ApiError(string, ...int) *echo.HTTPError
	JsonAPIError(string, int, string) *jsonapi.ErrorObject
	QueryParamTrue(string) (bool, bool)

	RequiredQueryParams(...string) (map[string]string, error)
	OptionalQueryParams(...string) map[string]string
	QParams(...string) (map[string]string, error)
}

type AuthedConfig

type AuthedConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper emw.Skipper
}

AuthedConfig config for Authed middleware.

type AuthedContextLookup

type AuthedContextLookup interface {
	Lookup(echo.Context) (echo.Context, error)
	Context(echo.Context) echo.Context
}

type CommonExtendable

type CommonExtendable interface {
	CommonExtend(interface{}) error
}

type CommonLinkable

type CommonLinkable interface {
	CommonLinks(*meta.Pagination) error
}

type CommonMetable

type CommonMetable interface {
	CommonMeta() error
}

type Extendable

type Extendable interface {
	Extend(interface{}) error
}

type HandlerFunc

type HandlerFunc func(ApiContext) error

type Linkable

type Linkable interface {
	Links(*meta.Pagination) error
}

type Metable

type Metable interface {
	Meta() error
}

type MethodHandler

type MethodHandler struct {
	Method     string
	Handler    echo.HandlerFunc
	MiddleWare []echo.MiddlewareFunc
}

type Route

type Route struct {
	Path     string
	Handlers []*MethodHandler
	Name     string
	ERoute   *echo.Route
}

func AddRoute

func AddRoute(path string) *Route

func RouteByName

func RouteByName(name string) (*Route, error)

func (*Route) Handle

func (route *Route) Handle(m string, hf HandlerFunc, mw ...echo.MiddlewareFunc) *Route

func (*Route) SetName

func (route *Route) SetName(n string) *Route

type RouteConfig

type RouteConfig struct {
	Routes     []*Route
	MiddleWare []echo.MiddlewareFunc
}
var Routing *RouteConfig

func (*RouteConfig) AddRoute

func (config *RouteConfig) AddRoute(path string) *Route

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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