webhelp.v1: gopkg.in/webhelp.v1/whfatal Index | Files

package whfatal

import "gopkg.in/webhelp.v1/whfatal"

Package whfatal uses panics to make early termination of http.Handlers easier. No other webhelp package depends on or uses this one.

Index

Package Files

fatal.go

func Catch Uses

func Catch(h http.Handler) http.Handler

Catch takes a Handler and returns a new one that works with Fatal, whfatal.Redirect, and whfatal.Error. Catch will also catch panics that are wherr.HTTPError errors. Catch should be placed *inside* a whlog.LogRequests handler, wherr.HandleWith handlers, and a few other handlers. Otherwise, the wrapper will be one of the things interrupted by Fatal calls.

func Error Uses

func Error(err error)

Error is like wherr.Handle but panics so that all additional request processing terminates. Implemented with Fatal()

IMPORTANT: must be used with whfatal.Catch, or else the http.ResponseWriter won't be able to be obtained. Because this requires whfatal.Catch, if you're writing a library intended to be used by others, please avoid this and other Fatal* methods. If you are writing a library intended to be used by yourself, you should probably avoid these methods anyway.

func Fatal Uses

func Fatal(handler func(w http.ResponseWriter, r *http.Request))

Fatal panics in a way that Catch understands to abort all additional request processing. Once request processing has been aborted, handler is called, if not nil. If handler doesn't write a response, a 500 will automatically be returned. whfatal.Error and whfatal.Redirect are implemented using this method.

IMPORTANT: must be used with whfatal.Catch, or else the http.ResponseWriter won't be able to be obtained. Because this requires whfatal.Catch, if you're writing a library intended to be used by others, please avoid this and other Fatal* methods. If you are writing a library intended to be used by yourself, you should probably avoid these methods anyway.

func Redirect Uses

func Redirect(redirectTo string)

Redirect is like whredir.Redirect but panics so all additional request processing terminates. Implemented with Fatal().

IMPORTANT: must be used with whfatal.Catch, or else the http.ResponseWriter won't be able to be obtained. Because this requires whfatal.Catch, if you're writing a library intended to be used by others, please avoid this and other Fatal* methods. If you are writing a library intended to be used by yourself, you should probably avoid these methods anyway.

Package whfatal imports 5 packages (graph) and is imported by 2 packages. Updated 2017-06-04. Refresh now. Tools for package owners.