httphandler

package
v0.0.0-...-8390b34 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2018 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GCI

func GCI(next http.HandlerFunc) http.HandlerFunc

GCI returns the GCI HTTP handler, which controls Go's GC to decrease service tail latency. Ideally, GCI handler should be the first middleware in the service process chain.

Example
f := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "Hi")
})
ts := httptest.NewServer(GCI(f))
defer ts.Close()

// Usual serving flow.
res, err := http.Get(ts.URL)
if err != nil {
	panic(err)
}
b, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil {
	panic(err)
}
fmt.Print(string(b))
Output:

==< Automatic GC Disabled <==
Hi

Types

This section is empty.

Jump to

Keyboard shortcuts

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