http

package
v0.0.0-...-ed3cc77 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2018 License: MIT Imports: 9 Imported by: 0

README

HTTP middlewares and utilities

GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddURLGenerator

func AddURLGenerator(router *mux.Router) func(http.Handler) http.Handler

AddURLGenerator is a middleware that adds an URLGenerator in the Request Context

func DebugRequest

func DebugRequest(next http.Handler) http.Handler

DebugRequest logs request start, status to its associated logger, if any

func UniqueID

func UniqueID(next http.Handler) http.Handler

UniqueID adds a unique ID to the Request Context, ResponseWriter and any associated Logger

func UniqueIDFromContext

func UniqueIDFromContext(ctx context.Context) string

UniqueIDFromContext retrieves the uniqueID from the Context

Types

type RouterDebug

type RouterDebug struct{ *mux.Router }

func (*RouterDebug) ServeHTTP

func (d *RouterDebug) ServeHTTP(w http.ResponseWriter, _ *http.Request)

type RouterURLGenerator

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

RouterURLGenerator implements URLGenerator using a mux.Router

func (*RouterURLGenerator) URL

func (r *RouterURLGenerator) URL(s *URLSpec) (url string, err error)

type Service

type Service struct {
	http.Server
	logging.Logger
}

func (*Service) Serve

func (w *Service) Serve()

func (*Service) Stop

func (w *Service) Stop()

type URLGenerator

type URLGenerator interface {
	URL(*URLSpec) (string, error)
}

URLGenerator generates a fully-fledged URL from the URLSpec

func URLGeneratorFromContext

func URLGeneratorFromContext(ctx context.Context) URLGenerator

URLGeneratorFromContext extracts the URLGenerator from the context

type URLSpec

type URLSpec struct {
	Route      string
	Parameters []string
}

URLSpec specifies how to build an URL with a route name and its parameters

func NewURLSpec

func NewURLSpec(name string, pairs ...string) *URLSpec

NewURLSpec is a helper to easily build an URLSPEC

Jump to

Keyboard shortcuts

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