handlers

package
v0.0.0-...-f1dd9c7 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Routes
	HealthRoute  = "/health"
	ReadyRoute   = "/ready"
	VersionRoute = "/version"

	// Ready statuses
	ReadyStatusOK    = "ok"
	ReadyStatusError = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthHandler

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

Struct representing a route handler for health / ready / version routes

func NewHealthHandler

func NewHealthHandler(db db.DB) *HealthHandler

NewHealthHandler creates and returns a new instance of a health handler

func (HealthHandler) Health

func (h HealthHandler) Health(w http.ResponseWriter, req *http.Request)

Health is an http handler used to fulfill "health" requests

func (HealthHandler) Ready

func (h HealthHandler) Ready(w http.ResponseWriter, req *http.Request)

Ready is an http handler used to fulfill "ready" requests

func (HealthHandler) Version

func (h HealthHandler) Version(w http.ResponseWriter, req *http.Request)

Version is an http handler used to fulfill "version" requests

type HealthResponse

type HealthResponse struct {
	Uptime int64 `json:"uptime"`
}

HealthResponse is a struct defining properties all "health" responses should contain

func NewHealthResponse

func NewHealthResponse() *HealthResponse

NewHealthResponse creates and returns a new instance of a health response

type ReadyResponse

type ReadyResponse struct {
	// Embeeded field
	*HealthResponse
	Service string `json:"service"`
	DB      string `json:"db"`
	DBType  string `json:"db-type"`
}

ReadyResponse is a struct defining properties all "ready" responses should contain

func NewReadyResponse

func NewReadyResponse(db db.DB) *ReadyResponse

NewReadyResponse creates and returns a new instance of a ready response

type VersionResponse

type VersionResponse struct {
	// Embeeded field
	*HealthResponse
	Version string `json:"version"`
}

VersionResponse is a struct defining properties all "version" responses should contain

func NewVersionResponse

func NewVersionResponse() *VersionResponse

NewVersionResponse creates and returns a new instance of a version response

Jump to

Keyboard shortcuts

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