http

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Port optional, http port to be exposed, 8080 by default.
	Port int

	// Name optional, http server name to be exposed.
	Name string

	// GracefulDuration optional, graceful duration to shut down the server, 12 seconds by default.
	GracefulDuration time.Duration
}

Config http config server.

type IServer

type IServer interface {
	Run() error
	Shutdown() error
}

func Server

func Server(sig chan os.Signal, cfg Config, opts ...Option) (IServer, error)

Server functions to initialize http server.

type Option

type Option interface {
	Apply(o *options)
}

func ErrorHandler

func ErrorHandler(fn func(err error, c echo.Context)) Option

ErrorHandler function to override server error handler.

func RegisterMiddleware

func RegisterMiddleware(fn echo.MiddlewareFunc) Option

RegisterMiddleware function to add middleware to server.

func RegisterMiddlewares

func RegisterMiddlewares(fn []echo.MiddlewareFunc) Option

RegisterMiddlewares function to add middleware to server.

func RegisterRoute

func RegisterRoute(fn func(*echo.Echo)) Option

RegisterRoute function to add route to server.

func RegisterRoutes

func RegisterRoutes(fn []func(*echo.Echo)) Option

RegisterRoutes function to add multi route to server.

Jump to

Keyboard shortcuts

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