Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: server/router/doc.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: router: Do not allocate merged array in Handle Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | server/router/handler.go » ('j') | server/router/handler.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 // Package router provides an HTTP router with support for middleware and groups .
6 // It wraps around julienschmidt/httprouter.
7 //
8 // Usage:
9 //
10 // r := router.New()
11 // r.Use(MiddlewareChain{Logger()})
12 // r.GET("/", MiddlewareChain{Foo()}, rootHandler) // Executes Logger, Foo, rootHandler in order
13 //
14 // authorized := r.Group("authorized")
15 // authorized.Use(MiddlewareChain{Authenticator(), Bar()})
16 // authorized.DELETE("/comment/:id", nil, delHandler) // Executes Logger, A uthenticator, Bar, delHandler in order (path: /authorized/comment/:id)
17 //
18 // func rootHandler(c *router.Context) {
19 // io.WriteString(c, "hello from the root route")
20 // }
21 //
22 // func Logger() router.Middleware {
23 // return func(c *router.Context, next router.Handler) {
24 // print("log before")
25 // c.Context = context.WithValue(c.Context, "x", "y")
26 // next(c)
27 // print("log after")
28 // }
29 // }
30 //
nodir 2016/06/15 20:14:43 it may be (or may be not) better to move this exam
nishanths 2016/06/16 00:14:18 Moved to example_test.go and removed this file. Co
31 package router
OLDNEW
« no previous file with comments | « no previous file | server/router/handler.go » ('j') | server/router/handler.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698