Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
Handler much like the standard http.Handler, but includes the request context in the ServeHTTP method
type HandlerFunc ¶
HandlerFunc much like the standard http.HandlerFunc, but includes the request context
type Middleware ¶
Middleware is a http.HandlerFunc that also includes a context and url params variables
type Q ¶
type Q struct {
// contains filtered or unexported fields
}
Q allows a list middleware functions to be created and run
func New ¶
func New(ops ...Middleware) *Q
New initializes the middleware chain with one or more handler functions. The returned pointer allows for additional middleware methods to be added or for the chain to be run.
q := que.New(foo, bar)
func (*Q) Add ¶
func (q *Q) Add(ops ...Middleware)
Add allows for one or more middleware handler functions to be added to the existing chain
q := que.New(cors, format) q.Add(auth)
func (*Q) Handle ¶
Handle accepts a Handler interface and returns the chain of existing middleware that includes the final Handler argument.
q := que.New(foo, bar) router.Get("/", q.Handle(handleRoot))
func (*Q) HandleFunc ¶
func (q *Q) HandleFunc(fn HandlerFunc) func(http.ResponseWriter, *http.Request)
HandleFunc returns the chain of existing middleware that includes the final HandlerFunc argument.
q := que.New(foo, bar) router.Get("/", q.HandleFunc(handleRoot))
func (*Q) Run ¶
Run executes the handler chain, which is most useful in tests
q := que.New(foo, bar) q.Add(func(c context.Context, w http.ResponseWriter, r *http.Request) { // perform tests here }) inst := aetest.NewInstance(nil) r := inst.NewRequest("GET", "/", nil) w := httpTest.NewRecorder() c := appengine.NewContext(r) q.Run(c, w, r)