route

package
v0.8.0-rc5 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2020 The Moov Authors Use of this source code is governed by an Apache License license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

View Source
var (
	IdempotentRecorder = lru.New()

	// Prometheus Metrics
	Histogram = prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
		Name: "http_response_duration_seconds",
		Help: "Histogram representing the http response durations",
	}, []string{"route"})
)

Functions

func CleanPath

func CleanPath(path string) string

CleanPath takes a URL path and formats it for Prometheus metrics

This method replaces /'s with -'s and strips out moov/base.ID() values from URL path slugs.

func HeaderUserID

func HeaderUserID(r *http.Request) string

HeaderUserID returns a wrapped UserID from an HTTP request's HTTP Headers

func PathUserID

func PathUserID(r *http.Request) string

PathUserID returns a wrapped UserID from an HTTP request's URL path

func ReadLimit

func ReadLimit(r *http.Request) int64

ReadLimit returns the "limit" query param from a request or zero if it's missing.

func ReadOffset

func ReadOffset(r *http.Request) int64

ReadOffset returns the "offset" query param from a request or zero if it's missing.

func ReadPathID

func ReadPathID(name string, r *http.Request) string

Types

type Responder

type Responder struct {
	XUserID    string
	XRequestID string
	// contains filtered or unexported fields
}

func NewResponder

func NewResponder(logger log.Logger, w http.ResponseWriter, r *http.Request) *Responder

func (*Responder) Log

func (r *Responder) Log(kvpairs ...interface{})

func (*Responder) Problem

func (r *Responder) Problem(err error)

func (*Responder) Respond

func (r *Responder) Respond(fn func(http.ResponseWriter))

func (*Responder) Span

func (r *Responder) Span() opentracing.Span

Jump to

Keyboard shortcuts

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