middleware

package
v0.0.0-...-f999dd2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: MIT Imports: 17 Imported by: 1

Documentation

Overview

Package middleware contains middlewares to aid the development of micro-services

Index

Constants

View Source
const PATKEY = "metrics.pattern"

PATKEY is the key used to store matched patterns in context

View Source
const RequestIDKey = "reqID"

Key to use when setting the request ID.

Variables

This section is empty.

Functions

func Apply404

func Apply404(h goji.Handler) goji.Handler

Apply404 is a middleware that supplies a custom 404 handler TODO: Change it to accept a custom 404 handler

func ApplyLog

func ApplyLog(l log.Logger) func(goji.Handler) goji.Handler

ApplyLog is a goji middleware that logs all requests to the logger provided

func ApplyRecoverer

func ApplyRecoverer(l log.Logger) func(goji.Handler) goji.Handler

func ApplyReqID

func ApplyReqID(h goji.Handler) goji.Handler

ApplyReqID is a middleware that injects a request ID into the context of each request. A request ID is a string of the form "host.example.com/random-0001", where "random" is a base62 random string that uniquely identifies this go process, and where the last number is an atomically incremented request counter.

func ApplyStats

func ApplyStats(h goji.Handler) goji.Handler

ApplyStats wraps a handler to track request counts and response status code counts name-spaced by goji Pattern. It will only include patterns that implement fmt.Stringer. For example, if a request matches the pattern /foo/:bar and returns a 204 status code, it will increment "foo.:bar.request" and "foo.:bar.response.204". In addition it updates a histogram with response latencies

largely influenced by https://github.com/metcalf/saypi

func ApplySubStats

func ApplySubStats(h goji.Handler) goji.Handler

ApplySubStats is a helper for using ApplyStats with nested muxes. It stores the pattern matched in the current mux but does not track any metrics independently. It should be included in every mux except the outer one.

func CrossDomainRequestAllower

func CrossDomainRequestAllower(handler goji.Handler) goji.Handler

func GetReqID

func GetReqID(ctx context.Context) string

GetReqID returns a request ID from the given context if one is present. Returns the empty string if a request ID cannot be found.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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