reverb

package module
v0.0.0-...-1ba6274 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 13 Imported by: 0

README

Reverb

Go Reference Go Report Card

Reverb is a package to help work with github.com/labstack/echo/v4.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPath         = errors.New("empty path")
	ErrEmptyRenderer     = errors.New("renderer is empty")
	ErrInvalidDuration   = errors.New("invalid duration")
	ErrInvalidHTTPMethod = errors.New("invalid http method")
	ErrInvalidLogger     = errors.New("invalid logger")
	ErrMissingRoutes     = errors.New("missing route")
)

Errors

Functions

func AddEntToContext

func AddEntToContext[T any](f func(context.Context, T) context.Context, db T) echo.MiddlewareFunc

AddEntToContext is used to add an ent.Client to an echo.Context. You would use this middlware with reverb.GraphQL. Usage: reverb.AddEntToContext(ent.NewContext, client)

func New

func New(opts ...Option) (*echo.Echo, error)

Types

type Auth

type Auth interface {
	Authenticate(echo.Context) (context.Context, bool)
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is a functional optional pattern

func Assets

func Assets(path string, fs fs.FS, browse bool) Option

Assets is used to serve embedded assets, i.e., css, js, or img.

func GraphQL

func GraphQL(path string, websockets bool, input *handler.Server, middleware ...echo.MiddlewareFunc) Option

GraphQL

func Path

func Path(method string, path string, handler echo.HandlerFunc, middleware ...echo.MiddlewareFunc) Option

Path

func Playground

func Playground(path, graph string, middleware ...echo.MiddlewareFunc) Option

Playground adds the GraphQL Playground. This is usually for debugging.

func Quiet

func Quiet() Option

Quiet hides the port information and the banner.

func Renderer

func Renderer(r echo.Renderer) Option

func SPA

func SPA(path string, files fs.FS) Option

SPA is a shorthand for Single Page Application

func SetLogger

func SetLogger(logger *slog.Logger) Option

SetLogger is used to set the logger. It overwrites any previous

func SetSecrets

func SetSecrets(secrets ...string) Option

SetSecrets

func ShowBanner

func ShowBanner() Option

ShowBanner is used to show the Echo banner.

func SinglePageApplication

func SinglePageApplication(path string, fs fs.FS) Option

SinglePageApplication is used to server a Single Page Application from an embed.FS

func Timeout

func Timeout(duration time.Duration) Option

Timeout sets the timeout to all routes.

func WithMiddleware

func WithMiddleware(middleware ...echo.MiddlewareFunc) Option

WithMiddleware adds a middleware to the base

func WithRateLimit

func WithRateLimit(limit rate.Limit) Option

WithRateLimit adds a rate limit middleware to the base

type Options

type Options []Option

Jump to

Keyboard shortcuts

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