Package webutil

import ""

Overview ▾


const (
    SessionName = "default"

func Assert

func Assert(err error)

Assert will panic the error given wrapped in an Error type if it is not nil. If it is nil, this function is a no-op.

type BuildState

type BuildState struct {
    Store      sessions.Store
    Make       func(sessions.Store, http.ResponseWriter, *http.Request) State
    ErrHandler func(http.ResponseWriter, *http.Request, Error)

func (BuildState) Handle

func (bs BuildState) Handle(h Handler) http.HandlerFunc

type Error

type Error struct {
    E error

Error is the only error that is captured by the handler in this package. All other errors are re-paniced.

func (Error) Error

func (e Error) Error() string

type Handler

type Handler func(State)

type State

type State interface {
    R() *http.Request
    W() http.ResponseWriter
    Params() map[string]string
    S() *sessions.Session

func NewState

func NewState(
    store sessions.Store,
    w http.ResponseWriter,
    r *http.Request,
) State