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

Side by Side Diff: go/src/infra/tricium/service/default/handlers.go

Issue 2149853003: Adds checking of template error (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Adds infra testing expectation Created 4 years, 5 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 handlers implements HTTP handlers for the default module. 5 // Package handlers implements HTTP handlers for the default module.
6 package handlers 6 package handlers
7 7
8 import ( 8 import (
9 "html/template"
10 "net/http" 9 "net/http"
11 10
12 "google.golang.org/appengine" 11 "google.golang.org/appengine"
13 "google.golang.org/appengine/taskqueue" 12 "google.golang.org/appengine/taskqueue"
13
14 "infra/tricium/service/common"
14 ) 15 )
15 16
16 func init() { 17 func init() {
17 http.HandleFunc("/", landingPageHandler) 18 http.HandleFunc("/", landingPageHandler)
18 http.HandleFunc("/analyze", analyzeHandler) 19 http.HandleFunc("/analyze", analyzeHandler)
19 } 20 }
20 21
21 var basePage = template.Must(template.ParseFiles("templates/base.html"))
22
23 func landingPageHandler(w http.ResponseWriter, r *http.Request) { 22 func landingPageHandler(w http.ResponseWriter, r *http.Request) {
24 » data := map[string]interface{}{ 23 » d := map[string]interface{}{
25 "Msg": "This service is under construction ...", 24 "Msg": "This service is under construction ...",
26 "ShowRequestForm": true, 25 "ShowRequestForm": true,
27 } 26 }
28 » basePage.Execute(w, data) 27 » common.ShowBasePage(w, d)
29 } 28 }
30 29
31 func analyzeHandler(w http.ResponseWriter, r *http.Request) { 30 func analyzeHandler(w http.ResponseWriter, r *http.Request) {
32 ctx := appengine.NewContext(r) 31 ctx := appengine.NewContext(r)
33 t := taskqueue.NewPOSTTask("/workflow-launcher/queue-handler", map[strin g][]string{"name": {"Analyze Request"}}) 32 t := taskqueue.NewPOSTTask("/workflow-launcher/queue-handler", map[strin g][]string{"name": {"Analyze Request"}})
34 if _, err := taskqueue.Add(ctx, t, "workflow-launcher-queue"); err != ni l { 33 if _, err := taskqueue.Add(ctx, t, "workflow-launcher-queue"); err != ni l {
35 http.Error(w, err.Error(), http.StatusInternalServerError) 34 http.Error(w, err.Error(), http.StatusInternalServerError)
36 return 35 return
37 } 36 }
38 » data := map[string]interface{}{ 37 » d := map[string]interface{}{
39 "Msg": "Dummy analysis request sent.", 38 "Msg": "Dummy analysis request sent.",
40 } 39 }
41 » basePage.Execute(w, data) 40 » common.ShowBasePage(w, d)
42 } 41 }
OLDNEW
« no previous file with comments | « go/src/infra/tricium/service/common/common.infra_testing ('k') | go/src/infra/tricium/service/gerrit-poller/handlers.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698