| Index: server/templates/middleware.go
|
| diff --git a/server/templates/middleware.go b/server/templates/middleware.go
|
| index fcd6398329f4ada4fd667c54d1fe18a30cd94011..be79abf3557ddb48f787e71a44257e7fc9b156ad 100644
|
| --- a/server/templates/middleware.go
|
| +++ b/server/templates/middleware.go
|
| @@ -1,31 +1,28 @@
|
| // Copyright 2015 The LUCI Authors. All rights reserved.
|
| // Use of this source code is governed under the Apache License, Version 2.0
|
| // that can be found in the LICENSE file.
|
|
|
| package templates
|
|
|
| import (
|
| "fmt"
|
| "net/http"
|
|
|
| - "github.com/julienschmidt/httprouter"
|
| - "golang.org/x/net/context"
|
| -
|
| - "github.com/luci/luci-go/server/middleware"
|
| + "github.com/luci/luci-go/server/router"
|
| )
|
|
|
| // WithTemplates is middleware that lazily loads template bundle and injects it
|
| // into the context.
|
| //
|
| // Wrapper reply with HTTP 500 if templates can not be loaded. Inner handler
|
| // receives context with all templates successfully loaded.
|
| -func WithTemplates(h middleware.Handler, b *Bundle) middleware.Handler {
|
| - return func(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| - c = Use(c, b) // calls EnsureLoaded and initializes b.err inside
|
| +func WithTemplates(b *Bundle) router.Middleware {
|
| + return func(c *router.Context, next router.Handler) {
|
| + c.Context = Use(c.Context, b) // calls EnsureLoaded and initializes b.err inside
|
| if b.err != nil {
|
| - http.Error(rw, fmt.Sprintf("Can't load HTML templates.\n%s", b.err), http.StatusInternalServerError)
|
| + http.Error(c.Writer, fmt.Sprintf("Can't load HTML templates.\n%s", b.err), http.StatusInternalServerError)
|
| return
|
| }
|
| - h(c, rw, r, p)
|
| + next(c)
|
| }
|
| }
|
|
|