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

Unified Diff: appengine/cmd/helloworld_mvm/backend/main.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Update tests 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 side-by-side diff with in-line comments
Download patch
Index: appengine/cmd/helloworld_mvm/backend/main.go
diff --git a/appengine/cmd/helloworld_mvm/backend/main.go b/appengine/cmd/helloworld_mvm/backend/main.go
index 23e62c89f6ed29985ff19d978aad7e5ddbdc5219..138e837fed040fd90ff10c36bad0eda1872c440b 100644
--- a/appengine/cmd/helloworld_mvm/backend/main.go
+++ b/appengine/cmd/helloworld_mvm/backend/main.go
@@ -9,25 +9,23 @@ package main
import (
"net/http"
- "github.com/julienschmidt/httprouter"
- "golang.org/x/net/context"
"google.golang.org/appengine"
"github.com/luci/luci-go/appengine/gaemiddleware"
- "github.com/luci/luci-go/server/middleware"
+ "github.com/luci/luci-go/server/router"
)
// base is the root of the middleware chain.
-func base(h middleware.Handler) httprouter.Handle {
- return gaemiddleware.BaseProd(h)
+func base() []router.Handler {
+ return gaemiddleware.BaseProd()
}
//// Routes.
func main() {
- router := httprouter.New()
- gaemiddleware.InstallHandlers(router, base)
- router.GET("/hi", base(sayHi))
+ router := router.New()
+ gaemiddleware.InstallHandlers(router, base())
+ router.GET("/hi", append(base(), sayHi)...)
http.DefaultServeMux.Handle("/", router)
appengine.Main()
@@ -35,6 +33,6 @@ func main() {
//// Handlers.
-func sayHi(c context.Context, w http.ResponseWriter, r *http.Request, p httprouter.Params) {
- w.Write([]byte("Hi, I'm backend"))
+func sayHi(c *router.Context) {
+ c.Writer.Write([]byte("Hi, I'm backend"))
}

Powered by Google App Engine
This is Rietveld 408576698