Version: v0.0.0-...-3f30213 Latest Latest

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

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 7 Imported by: 0



Package whgls provides webhelp tools that use grossness enabled by the github.com/jtolds/gls package. No other webhelp packages use github.com/jtolds/gls.

The predominant use case for github.com/jtolds/gls is to attach a current request's contextual information to all log lines kicked off by the request.



This section is empty.


This section is empty.


func Bind

func Bind(h http.Handler) http.Handler

Bind will make sure that Load works from any callstacks kicked off by this handler, via the magic of github.com/jtolds/gls. It is worthwhile to call Bind at the base of your handler stack and again after attaching any useful values you might want to include in logs to the request context.

func Load

func Load() *http.Request

Load will return the *http.Request bound to the current call stack by a Bind handler further up the stack.

func SetLogOutput

func SetLogOutput(
	logger func(ctx context.Context, format string, args ...interface{}))

SetLogOutput will configure the standard library's logger to use the provided logger that requires a context, such as AppEngine's loggers. This requires that the handler was wrapped with Bind. Note that this will cause all log messages without a context to be silently swallowed!

If whmon.RequestIds was in the handler callchain prior to Bind, this logger will also attach the Request ID to all log lines.

The benefit of this is that the standard library's logger (or some other logger that doesn't use contexts) can now be used naturally on a platform that requires contexts (like App Engine).

App Engine Example:

import (


var (
  handler = ...

func init() {
  http.Handle("/", whmon.RequestIds(whgls.Bind(handler)))


This section is empty.

Source Files

Jump to

Keyboard shortcuts

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