middleware

package module
v0.0.0-...-3e03080 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2015 License: BSD-2-Clause Imports: 15 Imported by: 0

README

Middleware in Go

GoDoc

Documentation

Overview

Middleware for the net/http library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GZip

func GZip(h http.Handler) http.Handler

GZip returns a handler which gzip's the response for all requests which accept that encoding.

func Inject

func Inject(script string, handler http.Handler) http.Handler

Inject appends JavaScript to the body of all HTML responses. It buffers all responses in memory (so use it selectively). It prints all parsing errors using the log package's Print function rather than returning 500s.

func Log

func Log(log io.Writer, h http.Handler) http.Handler

func NoCaching

func NoCaching(handler http.Handler) http.Handler

func ProxyRedirect

func ProxyRedirect(scheme, basePath string, handler http.Handler) http.Handler

ProxyRedirect joins basePath to the location header of all redirects generated the by handler. It also changes the scheme as provided.

p := httputil.NewSingleHostReverseProxy(u)
// force redirects to use https and prepend "/foo/bar" to all paths
h := middleware.ProxyRedirect("https", "/foo/bar", p)

TODO: Add refresh header handling

Types

This section is empty.

Jump to

Keyboard shortcuts

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