server

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App interface {
	http.Handler

	// Startup controls app startup
	Startup(ctx context.Context) error

	// Shutdown controls app shutdown
	Shutdown(ctx context.Context) error
}

App is a http.Handler with Startup and Shutdown lifecycle

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware for http.Handler

type Option

type Option func(s *Server)

func WithAddress

func WithAddress(address string) Option

func WithCORS

func WithCORS(enabled bool) Option

func WithDebug

func WithDebug(debug bool) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithMiddleware

func WithMiddleware(middleware Middleware) Option

func WithPathPrefix

func WithPathPrefix(prefix string) Option

func WithPort

func WithPort(port int) Option

func WithShutdownTimeout added in v0.1.5

func WithShutdownTimeout(timeout time.Duration) Option

func WithStartupTimeout added in v0.1.5

func WithStartupTimeout(timeout time.Duration) Option

type Server

type Server struct {
	http.Server
	App             App
	Address         string
	Port            int
	CertFile        string
	KeyFile         string
	PathPrefix      string
	StartupTimeout  time.Duration
	ShutdownTimeout time.Duration
	Logger          *zap.Logger
	Debug           bool
}

Server wraps the App with additional http and app lifecycle handling

func New

func New(app App, options ...Option) *Server

New create new Server

func (*Server) Run

func (s *Server) Run()

Jump to

Keyboard shortcuts

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