serve

package
v0.10.68 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Overview

Package serve provides a wrapper of net/http.Handler to be used as a filter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeHTTP

func ServeHTTP(ctx filters.FilterContext, h http.Handler)

Creates a response from a handler and a request.

It calls the handler's ServeHTTP method with an internal response writer that shares the status code, headers and the response body with the returned response. It blocks until the handler calls the response writer's WriteHeader, or starts writing the body, or returns. The written body is not buffered, but piped to the returned response's body.

Example, a simple file server:

var handler = http.StripPrefix(webRoot, http.FileServer(http.Dir(root)))

func (f *myFilter) Request(ctx filters.FilterContext) {
	serve.ServeHTTP(ctx, handler)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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