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

Side by Side Diff: appengine/cmd/helloworld/frontend/handler.go

Issue 1571393006: server/discovery: add discovery service (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@prpc-server
Patch Set: rebased Created 4 years, 11 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/discovery/discovery.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Package frontend implements HTTP server that handles requests to default 5 // Package frontend implements HTTP server that handles requests to default
6 // module. 6 // module.
7 package frontend 7 package frontend
8 8
9 import ( 9 import (
10 "net/http" 10 "net/http"
11 "strings" 11 "strings"
12 12
13 "github.com/julienschmidt/httprouter" 13 "github.com/julienschmidt/httprouter"
14 "golang.org/x/net/context" 14 "golang.org/x/net/context"
15 "google.golang.org/appengine" 15 "google.golang.org/appengine"
16 16
17 "github.com/luci/gae/service/info" 17 "github.com/luci/gae/service/info"
18 "github.com/luci/luci-go/appengine/cmd/helloworld/proto" 18 "github.com/luci/luci-go/appengine/cmd/helloworld/proto"
19 "github.com/luci/luci-go/appengine/gaeauth/server" 19 "github.com/luci/luci-go/appengine/gaeauth/server"
20 "github.com/luci/luci-go/appengine/gaemiddleware" 20 "github.com/luci/luci-go/appengine/gaemiddleware"
21 "github.com/luci/luci-go/server/auth" 21 "github.com/luci/luci-go/server/auth"
22 "github.com/luci/luci-go/server/discovery"
22 "github.com/luci/luci-go/server/middleware" 23 "github.com/luci/luci-go/server/middleware"
23 "github.com/luci/luci-go/server/prpc" 24 "github.com/luci/luci-go/server/prpc"
24 "github.com/luci/luci-go/server/templates" 25 "github.com/luci/luci-go/server/templates"
25 ) 26 )
26 27
27 // templateBundle is used to render HTML templates. It provides a base args 28 // templateBundle is used to render HTML templates. It provides a base args
28 // passed to all templates. 29 // passed to all templates.
29 var templateBundle = &templates.Bundle{ 30 var templateBundle = &templates.Bundle{
30 Loader: templates.FileSystemLoader("templates"), 31 Loader: templates.FileSystemLoader("templates"),
31 DebugMode: appengine.IsDevAppServer(), 32 DebugMode: appengine.IsDevAppServer(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 //// Routes. 72 //// Routes.
72 73
73 func init() { 74 func init() {
74 router := httprouter.New() 75 router := httprouter.New()
75 server.InstallHandlers(router, base) 76 server.InstallHandlers(router, base)
76 router.GET("/", base(auth.Authenticate(indexPage))) 77 router.GET("/", base(auth.Authenticate(indexPage)))
77 78
78 var api prpc.Server 79 var api prpc.Server
79 helloworld.RegisterGreeterServer(&api, &greeterService{}) 80 helloworld.RegisterGreeterServer(&api, &greeterService{})
81 discovery.Enable(&api)
80 api.InstallHandlers(router, base) 82 api.InstallHandlers(router, base)
81 83
82 http.DefaultServeMux.Handle("/", router) 84 http.DefaultServeMux.Handle("/", router)
83 } 85 }
84 86
85 //// Handlers. 87 //// Handlers.
86 88
87 func indexPage(c context.Context, w http.ResponseWriter, r *http.Request, p http router.Params) { 89 func indexPage(c context.Context, w http.ResponseWriter, r *http.Request, p http router.Params) {
88 templates.MustRender(c, w, "pages/index.html", nil) 90 templates.MustRender(c, w, "pages/index.html", nil)
89 } 91 }
OLDNEW
« no previous file with comments | « no previous file | server/discovery/discovery.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698