http

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2018 License: Apache-2.0 Imports: 8 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 recovering from failed requests

func RecoveryMiddleware

func RecoveryMiddleware(next http.HandlerFunc) http.HandlerFunc

RecoveryMiddleware for recovering from failed requests

Types

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 service

const (
	// Initializing represents a state before the service 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(*Service) error

Option defines a option for the HTTP service

func SetHealthCheck

func SetHealthCheck(hcf HealthCheckFunc) Option

SetHealthCheck option for setting the health check function

func SetPorts

func SetPorts(port int) Option

SetPorts option for setting the ports of the http service

func SetRoutes

func SetRoutes(rr []Route) Option

SetRoutes option for setting the routes of the http service

type ResponseWriter

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

ResponseWriter wrapper around the ResponseWriter to expose status

func NewResponseWriter

func NewResponseWriter(w http.ResponseWriter) *ResponseWriter

NewResponseWriter constructor

func (*ResponseWriter) Header

func (w *ResponseWriter) Header() http.Header

Header returns the header

func (*ResponseWriter) Status

func (w *ResponseWriter) Status() int

Status returns the http response status

func (*ResponseWriter) Write

func (w *ResponseWriter) Write(d []byte) (int, error)

Write to the internal ResponseWriter and sets the status if not set already

func (*ResponseWriter) WriteHeader

func (w *ResponseWriter) WriteHeader(code int)

WriteHeader writes the internal header and saves the status for retrieval

type Route

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

Route definition

func NewRoute

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

NewRoute returns a new route

type Service

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

Service implementation of HTTP

func New

func New(hg handlerGen, options ...Option) (*Service, error)

New returns a new service

func (*Service) Run

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

Run starts the processing

func (*Service) Shutdown

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

Shutdown the service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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