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

Side by Side Diff: go/src/infra/tricium/service/workflow-launcher/handlers.go

Issue 2149853003: Adds checking of template error (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: 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 workflow-launcher module. 5 // Package handlers implements HTTP handlers for the workflow-launcher module.
6 package handlers 6 package handlers
7 7
8 import ( 8 import (
9 "html/template" 9 "html/template"
10 "net/http" 10 "net/http"
11 11
12 "google.golang.org/appengine" 12 "google.golang.org/appengine"
13 "google.golang.org/appengine/taskqueue" 13 "google.golang.org/appengine/taskqueue"
14 ) 14 )
15 15
16 func init() { 16 func init() {
17 http.HandleFunc("/workflow-launcher/status", statusPageHandler) 17 http.HandleFunc("/workflow-launcher/status", statusPageHandler)
18 http.HandleFunc("/workflow-launcher/queue-handler", queueHandler) 18 http.HandleFunc("/workflow-launcher/queue-handler", queueHandler)
19 } 19 }
20 20
21 var basePage = template.Must(template.ParseFiles("templates/base.html")) 21 var basePage = template.Must(template.ParseFiles("templates/base.html"))
22 22
23 func statusPageHandler(w http.ResponseWriter, r *http.Request) { 23 func statusPageHandler(w http.ResponseWriter, r *http.Request) {
24 // TODO(emso): Add workflow launcher stats 24 // TODO(emso): Add workflow launcher stats
25 data := map[string]interface{}{ 25 data := map[string]interface{}{
26 "Msg": "Status of the Workflow Launcher ...", 26 "Msg": "Status of the Workflow Launcher ...",
27 } 27 }
28 » basePage.Execute(w, data) 28 » if e := basePage.Execute(w, data); e != nil {
29 » » http.Error(w, e.Error(), http.StatusInternalServerError)
30 » » return
31 » }
29 } 32 }
30 33
31 func queueHandler(w http.ResponseWriter, r *http.Request) { 34 func queueHandler(w http.ResponseWriter, r *http.Request) {
32 ctx := appengine.NewContext(r) 35 ctx := appengine.NewContext(r)
33 36
34 // TODO(emso): Process request (merge configs, compute workflow) and lau nch workflow 37 // TODO(emso): Process request (merge configs, compute workflow) and lau nch workflow
35 38
36 // Enqueue workflow listener task 39 // Enqueue workflow listener task
37 t := taskqueue.NewPOSTTask("/workflow-listener/queue-handler", map[strin g][]string{"name": {"Workflow Launched"}}) 40 t := taskqueue.NewPOSTTask("/workflow-listener/queue-handler", map[strin g][]string{"name": {"Workflow Launched"}})
38 » if _, err := taskqueue.Add(ctx, t, "workflow-listener-queue"); err != ni l { 41 » if _, e := taskqueue.Add(ctx, t, "workflow-listener-queue"); e != nil {
39 » » http.Error(w, err.Error(), http.StatusInternalServerError) 42 » » http.Error(w, e.Error(), http.StatusInternalServerError)
40 return 43 return
41 } 44 }
42 } 45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698