| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 helloworld | 5 package helloworld |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/http" | 9 "net/http" |
| 10 "runtime" | 10 "runtime" |
| 11 | 11 |
| 12 "appengine" | 12 "appengine" |
| 13 "appengine/user" | 13 "appengine/user" |
| 14 | 14 |
| 15 "golang.org/x/net/context" | 15 "golang.org/x/net/context" |
| 16 | 16 |
| 17 » "infra/libs/logging" | 17 » "github.com/luci/luci-go/common/logging" |
| 18 » "infra/libs/logging/gaelogger" | 18 » "github.com/luci/luci-go/common/logging/gaelogger" |
| 19 ) | 19 ) |
| 20 | 20 |
| 21 func init() { | 21 func init() { |
| 22 http.HandleFunc("/", requireLogin(rootHandler)) | 22 http.HandleFunc("/", requireLogin(rootHandler)) |
| 23 } | 23 } |
| 24 | 24 |
| 25 func requireLogin(handler http.HandlerFunc) http.HandlerFunc { | 25 func requireLogin(handler http.HandlerFunc) http.HandlerFunc { |
| 26 return func(w http.ResponseWriter, r *http.Request) { | 26 return func(w http.ResponseWriter, r *http.Request) { |
| 27 c := appengine.NewContext(r) | 27 c := appengine.NewContext(r) |
| 28 u := user.Current(c) | 28 u := user.Current(c) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 48 c := appengine.NewContext(r) | 48 c := appengine.NewContext(r) |
| 49 u := user.Current(c) | 49 u := user.Current(c) |
| 50 ctx := gaelogger.Use(context.Background(), c) | 50 ctx := gaelogger.Use(context.Background(), c) |
| 51 sayHi(ctx) | 51 sayHi(ctx) |
| 52 fmt.Fprintf(w, "Hello, %v!\n", u) | 52 fmt.Fprintf(w, "Hello, %v!\n", u) |
| 53 fmt.Fprintf(w, "GOROOT: %s\n", runtime.GOROOT()) | 53 fmt.Fprintf(w, "GOROOT: %s\n", runtime.GOROOT()) |
| 54 fmt.Fprintf(w, "GOARCH: %s\n", runtime.GOARCH) | 54 fmt.Fprintf(w, "GOARCH: %s\n", runtime.GOARCH) |
| 55 fmt.Fprintf(w, "GOOS: %s\n", runtime.GOOS) | 55 fmt.Fprintf(w, "GOOS: %s\n", runtime.GOOS) |
| 56 fmt.Fprintf(w, "Compiler: %s\n", runtime.Compiler) | 56 fmt.Fprintf(w, "Compiler: %s\n", runtime.Compiler) |
| 57 } | 57 } |
| OLD | NEW |