middleware

package
v0.0.0-...-21d4feb Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplicationJSON

func ApplicationJSON(h http.Handler) http.Handler

ApplicationJSON sets the content-type headr to JSON

func BuildErrorCatcher

func BuildErrorCatcher(sentryClient *raven.Client) func(h http.Handler) http.Handler

Middleware that catches panics, and:

  • logs them
  • optionally reports them to sentry - pass in "" if you don't want this
  • sends a 500 response

You can also use ThrowError() to raise an error that this middleware will catch, for example if you want an error to be reported to sentry

func CORS

func CORS(h http.Handler) http.Handler

CORS is a middleware to handle CORS requests

func GzipHandler

func GzipHandler(h http.Handler) http.Handler

GzipHandler is used to compress data

func MakeError

func MakeError(statusCode int, format string, params ...interface{}) error

func ThrowError

func ThrowError(statusCode int, format string, params ...interface{})

func XRequestID

func XRequestID(h http.Handler) http.Handler

XRequestID is a goji middleware to track requestID

Types

type HttpError

type HttpError struct {
	StatusCode int
	Message    string
}

An error that encapsulates an HTTP status code and message. Use ThrowError() to build an HttpError and raise it as a panic

func (HttpError) Error

func (h HttpError) Error() string

func (HttpError) WriteResponse

func (h HttpError) WriteResponse(w http.ResponseWriter)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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