router

package
v0.1.2-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunLocalServer

func RunLocalServer(router *Router, addr string, logger *log.Logger) error

Types

type Handler

type Handler interface {
	ServeHTTP(context.Context, events.LambdaFunctionURLRequest) Response
}

type HandlerFunc

func (HandlerFunc) ServeHTTP

type LambdaAdapter

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

func NewLambdaAdapter

func NewLambdaAdapter(router *Router, logger *log.Logger) *LambdaAdapter

func (*LambdaAdapter) ServeHTTP

func (la *LambdaAdapter) ServeHTTP(r *http.Request) Response

type Middleware

type Middleware struct {
	Func   MiddlewareFunc
	Config MiddlewareConfig
}

type MiddlewareConfig

type MiddlewareConfig struct {
	ExcludedRoutes  []string
	ExcludedMethods []string
	ExcludedHeaders map[string]string
}

type MiddlewareFunc

type MiddlewareFunc func(Handler) Handler

type Response

type Response struct {
	StatusCode int               `json:"statusCode"`
	Headers    map[string]string `json:"headers"`
	Body       interface{}       `json:"body"`
}

type Router

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

func NewRouter

func NewRouter(logger *log.Logger) *Router

func (*Router) AddRoute

func (r *Router) AddRoute(method, path string, handler Handler)

func (*Router) HandleRequest

func (r *Router) HandleRequest(ctx context.Context, req events.LambdaFunctionURLRequest) Response

func (*Router) SetMethodNotAllowedHandler

func (r *Router) SetMethodNotAllowedHandler(handler Handler)

func (*Router) SetNotFoundHandler

func (r *Router) SetNotFoundHandler(handler Handler)

func (*Router) SetPanicHandler

func (r *Router) SetPanicHandler(handler func(context.Context, events.LambdaFunctionURLRequest) Response)

func (*Router) SetStripTrailingSlash

func (r *Router) SetStripTrailingSlash(strip bool)

func (*Router) UsePost

func (r *Router) UsePost(mw MiddlewareFunc, config MiddlewareConfig)

func (*Router) UsePre

func (r *Router) UsePre(mw MiddlewareFunc, config MiddlewareConfig)

Jump to

Keyboard shortcuts

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