internal

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewZapLogger added in v0.0.26

func NewZapLogger(development, verbose bool, logFile string) (*zap.SugaredLogger, error)

Types

type AppEndpoint added in v0.0.25

type AppEndpoint struct {
	Handler AppHandler
	Server  *Server
}

func (AppEndpoint) ServeHTTP added in v0.0.25

func (a AppEndpoint) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AppHandler added in v0.0.25

type AppHandler func(http.ResponseWriter, *http.Request) error

type EndpointMetricsMiddleware added in v0.0.20

type EndpointMetricsMiddleware struct {
	MetricsCollector middleware.Middleware
}

func (*EndpointMetricsMiddleware) AddMiddleware added in v0.0.20

func (m *EndpointMetricsMiddleware) AddMiddleware(path string, handler http.Handler) http.Handler

type Error

type Error interface {
	error
	Status() int
}

Error represents a handler error. It provides methods for a HTTP status code and embeds the built-in error interface.

type Middleware added in v0.0.20

type Middleware func(http.Handler) http.Handler

type PerRouteMiddleware added in v0.0.20

type PerRouteMiddleware interface {
	AddMiddleware(path string, handler http.Handler) http.Handler
}

PerRouteMiddleware adds middleware that requires information about the specific paths used (e.g. HTTP metric collection, which needs to know what path a given function is registered to).

type Server

type Server struct {
	ServerConfig
	Info                ServerInfo
	PerRouteMiddlewares []PerRouteMiddleware
	Logger              *zap.SugaredLogger
	Router              *httprouter.Router
	MaxShutdownTime     time.Duration
	IsHealthy           int32
	// contains filtered or unexported fields
}

Server describes the server configuration

func NewServer added in v0.0.26

func NewServer(config ServerConfig, info ServerInfo) *Server

func (*Server) AddEndpoint added in v0.0.25

func (s *Server) AddEndpoint(h AppHandler) *AppEndpoint

func (*Server) Route added in v0.0.20

func (s *Server) Route(method, path string, handler http.Handler)

func (*Server) Shutdown added in v0.0.25

func (s *Server) Shutdown()

func (*Server) Start

func (s *Server) Start()

Start initializes a server instance and start the server

func (*Server) SubRoute added in v0.0.20

func (s *Server) SubRoute(path string) *SubRouter

type ServerConfig added in v0.0.26

type ServerConfig struct {
	LogFile     string
	Port        int `valid:"range(1|65535)~'port' must be a valid port between 1-65535, required~Port must be specified"`
	Development bool
	Verbose     bool
}

ServerConfig contains all the configuration options for the server. Everything here should be operator-accessible

type ServerInfo added in v0.0.4

type ServerInfo struct {
	Version string
	Commit  string
	Date    string
	BuiltBy string
}

ServerInfo contains some metadata about the server. This information is typically baked in at compile time, so in most development cases these fields will be empty.

type StatusError

type StatusError struct {
	Code int
	Err  error
}

StatusError represents an error with an associated HTTP status code.

func (StatusError) Error

func (se StatusError) Error() string

Allows StatusError to satisfy the error interface.

func (StatusError) Status

func (se StatusError) Status() int

Status returns our HTTP status code.

type SubRouter added in v0.0.20

type SubRouter struct {
	// The full path prefix that this SubRouter is adding to
	Path string
	// The router to add routes to
	Server *Server
	// Middleware to append to all child routes. These get appended to an extra subroutes
	Middlewares []Middleware
}

func (*SubRouter) AddMiddleware added in v0.0.20

func (s *SubRouter) AddMiddleware(m ...Middleware)

func (*SubRouter) Route added in v0.0.20

func (s *SubRouter) Route(method, path string, handler http.Handler)

func (*SubRouter) RouteFiles added in v0.0.20

func (s *SubRouter) RouteFiles(path string, root http.FileSystem)

func (*SubRouter) SubRoute added in v0.0.20

func (s *SubRouter) SubRoute(path string) *SubRouter

Jump to

Keyboard shortcuts

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