echo

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PluginsRoot = root + ".plugins"
)

Variables

This section is empty.

Functions

func ConfigAdd

func ConfigAdd(path string)

func ErrorHandlerJSON

func ErrorHandlerJSON(err error, c e.Context)

ErrorHandlerJSON implements JSON content type error handler.

func ErrorHandlerString

func ErrorHandlerString(err error, c e.Context)

ErrorHandlerString implements plain text content type error handler.

func ErrorStatusCode

func ErrorStatusCode(err error) int

ErrorStatusCode translates to the respective status code.

Types

type Options

type Options struct {
	HideBanner   bool
	DisableHTTP2 bool `config:"disableHTTP2"`
	Port         int
	Type         string
	Protocol     string
	TLS          struct {
		Enabled bool
		Type    string
		Auto    struct {
			Host string
		}
		File struct {
			Cert string
			Key  string
		}
	} `config:"tls"`
	Json struct {
		Pretty struct {
			Enabled bool
		}
	}
}

Options echo server options.

func NewOptions

func NewOptions() (*Options, error)

NewOptions returns options from config file or environment vars.

func NewOptionsWithPath

func NewOptionsWithPath(path string) (opts *Options, err error)

NewOptionsWithPath unmarshals a given key path into options and returns it.

type Plugin

type Plugin func(context.Context, *Server) error

Plugin defines an echo server Plugin function to execute.

type Server

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

Server represents a echo server.

func NewServer

func NewServer(ctx context.Context, plugins ...Plugin) *Server

NewServer returns a new echo server with default options.

func NewServerWithConfigPath

func NewServerWithConfigPath(ctx context.Context, path string) (*Server, error)

NewServerWithConfigPath returns a new echo server with options from config path.

func NewServerWithOptions

func NewServerWithOptions(ctx context.Context, opt *Options, plugins ...Plugin) *Server

NewServerWithOptions returns a new echo server with options.

func (*Server) Add

func (s *Server) Add(method string, path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

Add registers the handler and middlewares for method route at path.

func (*Server) Any

func (s *Server) Any(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) []*echo.Route

Any registers the handler and middlewares for all method routes at path.

func (*Server) CONNECT

func (s *Server) CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

CONNECT registers the handler and middlewares for CONNECT route at path.

func (*Server) DELETE

func (s *Server) DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

DELETE registers the handler and middlewares for DELETE route at path.

func (*Server) File

func (s *Server) File(path, file string, m ...echo.MiddlewareFunc) *echo.Route

File registers a path to a server file.

func (*Server) GET

func (s *Server) GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

GET registers the handler and middlewares for GET route at path.

func (*Server) Group

func (s *Server) Group(prefix string, m ...echo.MiddlewareFunc) *echo.Group

Group creates a router group with prefix and registers middlewares.

func (*Server) HEAD

func (s *Server) HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

HEAD registers the handler and middlewares for HEAD route at path.

func (*Server) Instance

func (s *Server) Instance() *echo.Echo

Instance returns the wrapped echo server instance.

func (*Server) Match

func (s *Server) Match(methods []string, path string, handler echo.HandlerFunc, middleware ...echo.MiddlewareFunc) []*echo.Route

Match registers the handler and middlewares for method routes at path.

func (*Server) OPTIONS

func (s *Server) OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

OPTIONS registers the handler and middlewares for OPTIONS route at path.

func (*Server) Options

func (s *Server) Options() *Options

Options returns echo server options.

func (*Server) PATCH

func (s *Server) PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

PATCH registers the handler and middlewares for PATCH route at path.

func (*Server) POST

func (s *Server) POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

POST registers the handler and middlewares for POST route at path.

func (*Server) PUT

func (s *Server) PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

PUT registers the handler and middlewares for PUT route at path.

func (*Server) Pre

func (s *Server) Pre(middleware ...echo.MiddlewareFunc)

Pre registers middlewares that will run before router.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context)

Serve starts echo server.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context)

Shutdown stops echo server.

func (*Server) Static

func (s *Server) Static(prefix, root string) *echo.Route

Static registers a static path to server static files at root dir.

func (*Server) Use

func (s *Server) Use(middleware ...echo.MiddlewareFunc)

Use registers middlewares that will run after router.

type WrappedLogger

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

WrappedLogger represents a wrapped logger with util methods.

func WrapLogger

func WrapLogger(l log.Logger) *WrappedLogger

WrapLogger wraps an instace of logger interface.

func (WrappedLogger) Debug

func (wl WrappedLogger) Debug(i ...interface{})

Debug logs a debug message.

func (WrappedLogger) Debugf

func (wl WrappedLogger) Debugf(s string, i ...interface{})

Debugf logs a formatted debug message.

func (WrappedLogger) Debugj

func (wl WrappedLogger) Debugj(j l.JSON)

Debugj not implemented yet.

func (WrappedLogger) Error

func (wl WrappedLogger) Error(i ...interface{})

Error logs an error message.

func (WrappedLogger) Errorf

func (wl WrappedLogger) Errorf(s string, i ...interface{})

Errorf logs a formatted error message.

func (WrappedLogger) Errorj

func (wl WrappedLogger) Errorj(j l.JSON)

Warnj not implemented yet.

func (WrappedLogger) Fatal

func (wl WrappedLogger) Fatal(i ...interface{})

Fatal logs a fatal message.

func (WrappedLogger) Fatalf

func (wl WrappedLogger) Fatalf(s string, i ...interface{})

Fatalf logs a formatted fatal message.

func (WrappedLogger) Fatalj

func (wl WrappedLogger) Fatalj(j l.JSON)

Warnj not implemented yet.

func (WrappedLogger) Info

func (wl WrappedLogger) Info(i ...interface{})

Warnf logs an info message.

func (WrappedLogger) Infof

func (wl WrappedLogger) Infof(s string, i ...interface{})

Infof logs a formatted info message.

func (WrappedLogger) Infoj

func (wl WrappedLogger) Infoj(j l.JSON)

Infoj not implemented yet.

func (WrappedLogger) Level

func (wl WrappedLogger) Level() l.Lvl

Level not implemented yet.

func (WrappedLogger) Output

func (wl WrappedLogger) Output() io.Writer

Output returns logger output writer.

func (WrappedLogger) Panic

func (wl WrappedLogger) Panic(i ...interface{})

Warnj not implemented yet.

func (WrappedLogger) Panicf

func (wl WrappedLogger) Panicf(format string, args ...interface{})

Warnj not implemented yet.

func (WrappedLogger) Panicj

func (wl WrappedLogger) Panicj(j l.JSON)

Warnj not implemented yet.

func (WrappedLogger) Prefix

func (wl WrappedLogger) Prefix() string

Prefix not implemented yet.

func (WrappedLogger) Print

func (wl WrappedLogger) Print(i ...interface{})

Print logs a message.

func (WrappedLogger) Printf

func (wl WrappedLogger) Printf(s string, i ...interface{})

Print logs a formatted message.

func (WrappedLogger) Printj

func (wl WrappedLogger) Printj(j l.JSON)

Level not implemented yet.

func (WrappedLogger) SetHeader

func (wl WrappedLogger) SetHeader(h string)

SetHeader not implemented yet.

func (WrappedLogger) SetLevel

func (wl WrappedLogger) SetLevel(v l.Lvl)

SetLevel not implemented yet.

func (WrappedLogger) SetOutput

func (wl WrappedLogger) SetOutput(w io.Writer)

Warnj not implemented yet.

func (WrappedLogger) SetPrefix

func (wl WrappedLogger) SetPrefix(p string)

SetPrefix not implemented yet.

func (WrappedLogger) Warn

func (wl WrappedLogger) Warn(i ...interface{})

Warn logs a warn message.

func (WrappedLogger) Warnf

func (wl WrappedLogger) Warnf(s string, i ...interface{})

Warnf logs a formatted warn message.

func (WrappedLogger) Warnj

func (wl WrappedLogger) Warnj(j l.JSON)

Warnj not implemented yet.

Jump to

Keyboard shortcuts

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