http

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultMiddleware

func DefaultMiddleware(next http.HandlerFunc) http.HandlerFunc

DefaultMiddleware which handles Logging and Recover middleware

func LoggingMiddleware

func LoggingMiddleware(next http.HandlerFunc) http.HandlerFunc

LoggingMiddleware for handling logging and metrics

func RecoveryMiddleware

func RecoveryMiddleware(next http.HandlerFunc) http.HandlerFunc

RecoveryMiddleware for recovering from failed requests

Types

type Component added in v0.2.0

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

Component implementation of HTTP.

func New

func New(hg handlerGen, oo ...Option) (*Component, error)

New returns a new component.

func (*Component) Run added in v0.2.0

func (s *Component) Run(ctx context.Context) error

Run starts the HTTP server.

func (*Component) Shutdown added in v0.2.0

func (s *Component) Shutdown(ctx context.Context) error

Shutdown the component.

type HealthCheckFunc

type HealthCheckFunc func() HealthStatus

HealthCheckFunc defines a function for implementing a health check.

type HealthStatus

type HealthStatus int

HealthStatus type represanting the health of a component.

const (
	// Initializing represents a state before the component is Healthy.
	Initializing HealthStatus = 0
	// Healthy represents a state defining a healthy state.
	Healthy HealthStatus = 1
	// Unhealthy represents a state defining a unhealthy state.
	Unhealthy HealthStatus = 2
)

type Option

type Option func(*Component) error

Option defines a option for the HTTP service

func HealthCheck added in v0.2.0

func HealthCheck(hcf HealthCheckFunc) Option

HealthCheck option for setting the health check function

func Port added in v0.2.0

func Port(port int) Option

Port option for setting the ports of the http service

func Routes added in v0.2.0

func Routes(rr []Route) Option

Routes option for setting the routes of the http service

type Route

type Route struct {
	Pattern string
	Method  string
	Handler http.HandlerFunc
}

Route definition

func NewRoute

func NewRoute(p string, m string, pr sync.Processor) Route

NewRoute returns a new route from a generic handler

func NewRouteRaw added in v0.2.0

func NewRouteRaw(p string, m string, h http.HandlerFunc) Route

NewRouteRaw returns a new route from a HTTP handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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