OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be found | 2 // Use of this source code is governed by a BSD-style license that can be found |
3 // in the LICENSE file. | 3 // in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "database/sql" | 8 "database/sql" |
9 "flag" | 9 "flag" |
10 "fmt" | 10 "fmt" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // indexTemplate is the main index.html page we serve. | 28 // indexTemplate is the main index.html page we serve. |
29 indexTemplate *template.Template = nil | 29 indexTemplate *template.Template = nil |
30 | 30 |
31 // db is the database, nil if we don't have an SQL database to store dat
a into. | 31 // db is the database, nil if we don't have an SQL database to store dat
a into. |
32 db *sql.DB = nil | 32 db *sql.DB = nil |
33 ) | 33 ) |
34 | 34 |
35 // flags | 35 // flags |
36 var ( | 36 var ( |
37 port = flag.String("port", ":8000", "HTTP service address (e.g., '
:8000')") | 37 port = flag.String("port", ":8000", "HTTP service address (e.g., '
:8000')") |
38 » doOauth = flag.Bool("oauth", true, "Run through the OAuth 2.0 flow on
startup.") | 38 » doOauth = flag.Bool("oauth", true, "Run through the OAuth 2.0 flow on
startup, otherwise use a GCE service account.") |
39 gitRepoDir = flag.String("git_repo_dir", "../../../skia", "Directory loc
ation for the Skia repo.") | 39 gitRepoDir = flag.String("git_repo_dir", "../../../skia", "Directory loc
ation for the Skia repo.") |
40 ) | 40 ) |
41 | 41 |
42 var ( | 42 var ( |
43 data *Data | 43 data *Data |
44 ) | 44 ) |
45 | 45 |
46 func init() { | 46 func init() { |
47 rand.Seed(time.Now().UnixNano()) | 47 rand.Seed(time.Now().UnixNano()) |
48 | 48 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 // Resources are served directly. | 139 // Resources are served directly. |
140 http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./")))) | 140 http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./")))) |
141 | 141 |
142 http.HandleFunc("/", autogzip.HandleFunc(mainHandler)) | 142 http.HandleFunc("/", autogzip.HandleFunc(mainHandler)) |
143 http.HandleFunc("/json/", autogzip.HandleFunc(jsonHandler)) | 143 http.HandleFunc("/json/", autogzip.HandleFunc(jsonHandler)) |
144 | 144 |
145 log.Println("Ready to serve.") | 145 log.Println("Ready to serve.") |
146 log.Fatal(http.ListenAndServe(*port, nil)) | 146 log.Fatal(http.ListenAndServe(*port, nil)) |
147 } | 147 } |
OLD | NEW |