http

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: Apache-2.0, BSD-3-Clause Imports: 6 Imported by: 0

README

Package http is based on a copy of net/http.

Documentation

Overview

Package http provides helpers for HTTP servers.

Index

Constants

This section is empty.

Variables

View Source
var ErrHandlerTimeout = errors.New("http: Handler timeout")

ErrHandlerTimeout is returned on ResponseWriter Write calls in handlers which have timed out.

Functions

func TimeoutHandler

func TimeoutHandler(h http.Handler, dt time.Duration, msg string) http.Handler

TimeoutHandler returns a Handler that runs h with the given time limit.

The new Handler calls h.ServeHTTP to handle each request, but if a call runs for longer than its time limit, the handler responds with a 504 Gateway Timeout error and the given message in its body. (If msg is empty, a suitable default message will be sent.) After such a timeout, writes by h to its ResponseWriter will return ErrHandlerTimeout.

TimeoutHandler buffers all Handler writes to memory and does not support the Hijacker or Flusher interfaces.

Types

This section is empty.

Jump to

Keyboard shortcuts

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