| Index: appengine/cmd/helloworld/frontend/handler.go
|
| diff --git a/appengine/cmd/helloworld/frontend/handler.go b/appengine/cmd/helloworld/frontend/handler.go
|
| index 72c18679594e6871be3af931f1b8483c70c8d0b3..b696b2fdda13e4e2b9bd80569e5dc4a3b5becf87 100644
|
| --- a/appengine/cmd/helloworld/frontend/handler.go
|
| +++ b/appengine/cmd/helloworld/frontend/handler.go
|
| @@ -11,7 +11,6 @@ import (
|
| "strings"
|
|
|
| "github.com/golang/protobuf/proto"
|
| - "github.com/julienschmidt/httprouter"
|
| "golang.org/x/net/context"
|
| "google.golang.org/appengine"
|
|
|
| @@ -21,8 +20,8 @@ import (
|
| "github.com/luci/luci-go/appengine/gaemiddleware"
|
| "github.com/luci/luci-go/server/auth"
|
| "github.com/luci/luci-go/server/discovery"
|
| - "github.com/luci/luci-go/server/middleware"
|
| "github.com/luci/luci-go/server/prpc"
|
| + "github.com/luci/luci-go/server/router"
|
| "github.com/luci/luci-go/server/templates"
|
| )
|
|
|
| @@ -56,21 +55,23 @@ var templateBundle = &templates.Bundle{
|
| }
|
|
|
| // pageBase is middleware for page handlers.
|
| -func pageBase(h middleware.Handler) httprouter.Handle {
|
| - h = auth.Use(h, auth.Authenticator{server.CookieAuth})
|
| - h = templates.WithTemplates(h, templateBundle)
|
| - return gaemiddleware.BaseProd(h)
|
| +func pageBase() []router.Handler {
|
| + return append(
|
| + gaemiddleware.BaseProd(),
|
| + templates.WithTemplates(templateBundle),
|
| + auth.Use(auth.Authenticator{server.CookieAuth}),
|
| + )
|
| }
|
|
|
| // prpcBase is middleware for pRPC API handlers.
|
| -func prpcBase(h middleware.Handler) httprouter.Handle {
|
| +func prpcBase() []router.Handler {
|
| // OAuth 2.0 with email scope is registered as a default authenticator
|
| // by importing "github.com/luci/luci-go/appengine/gaeauth/server".
|
| // No need to setup an authenticator here.
|
| //
|
| // For authorization checks, we use per-service decorators; see
|
| // service registration code.
|
| - return gaemiddleware.BaseProd(h)
|
| + return gaemiddleware.BaseProd()
|
| }
|
|
|
| //// Routes.
|
| @@ -94,9 +95,9 @@ func checkAPIAccess(c context.Context, methodName string, req proto.Message) (co
|
| }
|
|
|
| func init() {
|
| - router := httprouter.New()
|
| - gaemiddleware.InstallHandlers(router, pageBase)
|
| - router.GET("/", pageBase(auth.Authenticate(indexPage)))
|
| + router := router.New()
|
| + gaemiddleware.InstallHandlers(router, pageBase())
|
| + router.GET("/", append(pageBase(), auth.Authenticate(), indexPage)...)
|
|
|
| var api prpc.Server
|
| helloworld.RegisterGreeterServer(&api, &helloworld.DecoratedGreeter{
|
| @@ -104,13 +105,13 @@ func init() {
|
| Prelude: checkAPIAccess,
|
| })
|
| discovery.Enable(&api)
|
| - api.InstallHandlers(router, prpcBase)
|
| + api.InstallHandlers(router, prpcBase())
|
|
|
| http.DefaultServeMux.Handle("/", router)
|
| }
|
|
|
| //// Handlers.
|
|
|
| -func indexPage(c context.Context, w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| - templates.MustRender(c, w, "pages/index.html", nil)
|
| +func indexPage(c *router.Context) {
|
| + templates.MustRender(c.Context, c.Writer, "pages/index.html", nil)
|
| }
|
|
|