router

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandlerWrapper

func HandlerWrapper(emfhandler HandlerFunc) echo.HandlerFunc

HandlerWrapper wraps EMFHandlerFuncs into echo.HandlerFuncs

func MiddlewaresWrapper

func MiddlewaresWrapper(mids []Middleware) []echo.MiddlewareFunc

MiddlewaresWrapper takes in a list of Middlewares and returns a list of echo.MiddlewareFuncs

Types

type EchoRouter

type EchoRouter interface {
	Add(string, string, echo.HandlerFunc, ...echo.MiddlewareFunc) *echo.Route
	Any(string, echo.HandlerFunc, ...echo.MiddlewareFunc) []*echo.Route
	Pre(middleware ...echo.MiddlewareFunc)
	Use(middleware ...echo.MiddlewareFunc)
}

EchoRouter sets up the Request Handlers for the server.

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group is a set of sub-routes for a specified route. It can be used for inner routes that share a common middleware or functionality that should be separate from the parent echo instance while still inheriting from it.

func (*Group) Add

func (g *Group) Add(method, path string, h HandlerFunc, middleware ...Middleware) *echo.Route

Add implements `Echo#Add()` for sub-routes within the Group.

func (*Group) Any

func (g *Group) Any(path string, h HandlerFunc, m ...Middleware) []*echo.Route

Any implements `Echo#Any()` for sub-routes within the Group.

func (*Group) CONNECT

func (g *Group) CONNECT(path string, h HandlerFunc, m ...Middleware) *echo.Route

CONNECT implements `Echo#CONNECT()` for sub-routes within the Group.

func (*Group) DELETE

func (g *Group) DELETE(path string, h HandlerFunc, m ...Middleware) *echo.Route

DELETE implements `Echo#DELETE()` for sub-routes within the Group.

func (*Group) GET

func (g *Group) GET(path string, h HandlerFunc, m ...Middleware) *echo.Route

GET implements `Echo#GET()` for sub-routes within the Group.

func (*Group) Group

func (g *Group) Group(prefix string, middleware ...Middleware) *Group

Group creates a new sub-group with prefix and optional sub-group-level middleware.

func (*Group) HEAD

func (g *Group) HEAD(path string, h HandlerFunc, m ...Middleware) *echo.Route

HEAD implements `Echo#HEAD()` for sub-routes within the Group.

func (*Group) Match

func (g *Group) Match(methods []string, path string, h HandlerFunc, m ...Middleware) []*echo.Route

Match implements `Echo#Match()` for sub-routes within the Group.

func (*Group) OPTIONS

func (g *Group) OPTIONS(path string, h HandlerFunc, m ...Middleware) *echo.Route

OPTIONS implements `Echo#OPTIONS()` for sub-routes within the Group.

func (*Group) PATCH

func (g *Group) PATCH(path string, h HandlerFunc, m ...Middleware) *echo.Route

PATCH implements `Echo#PATCH()` for sub-routes within the Group.

func (*Group) POST

func (g *Group) POST(path string, h HandlerFunc, m ...Middleware) *echo.Route

POST implements `Echo#POST()` for sub-routes within the Group.

func (*Group) PUT

func (g *Group) PUT(path string, h HandlerFunc, m ...Middleware) *echo.Route

PUT implements `Echo#PUT()` for sub-routes within the Group.

func (*Group) TRACE

func (g *Group) TRACE(path string, h HandlerFunc, m ...Middleware) *echo.Route

TRACE implements `Echo#TRACE()` for sub-routes within the Group.

func (*Group) Use

func (g *Group) Use(middleware ...Middleware)

Use implements `Echo#Use()` for sub-routes within the Group.

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient issues HTTP Requests and performs error handling.

type HandlerFunc

type HandlerFunc = func(ctx context.EMFContext) error

HandlerFunc is equivalent to the echo HandlerFunc interface to avoid the middleware package having to import it

func GoHandlerToEMFHandler

func GoHandlerToEMFHandler(gohandler http.Handler) HandlerFunc

GoHandlerToEMFHandler converts a standard go http.Handler function into a router.HandlerFunc

type Middleware

type Middleware interface {
	Wrapper(next echo.HandlerFunc) echo.HandlerFunc
}

Middleware is used to for providing additional logic on endpoints registered with a Controller.

type MiddlewareFunc

type MiddlewareFunc = echo.MiddlewareFunc

MiddlewareFunc is equivalent to the echo MiddlewareFunc interface to avoid the middleware package having to import it

type Option

type Option func(*Router)

Option provides the client a callback that is used to dynamically specify attributes for a Controller.

func WithRouter

func WithRouter(router *echo.Echo) Option

WithRouter is an Option for specifying the Router for a Controller.

type Router

type Router struct {
	Logger echo.Logger
	// contains filtered or unexported fields
}

Router is a generic router type that is used to register and dispatch routes

func New

func New(opts ...Option) *Router

New is a variadic constructor for a Controller.

func (*Router) NewGroup

func (r *Router) NewGroup(prefix string, m ...Middleware) (g *Group)

NewGroup creates a new router group with prefix and optional group-level middleware.

func (*Router) Pre

func (r *Router) Pre(middleware ...MiddlewareFunc)

Pre exposes the echo.Pre method to callers for registering pre-middlewares

func (*Router) Use

func (r *Router) Use(middleware ...MiddlewareFunc)

Use exposes the echo.Use method to callers for registering middleware

func (*Router) UseGlobalMiddlewares

func (r *Router) UseGlobalMiddlewares(m ...Middleware)

UseGlobalMiddlewares registers global middlewares for all endpoints

Jump to

Keyboard shortcuts

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