Chromium Code Reviews| Index: go/src/infra/tricium/service/default/handlers.go |
| diff --git a/go/src/infra/tricium/service/default/handlers.go b/go/src/infra/tricium/service/default/handlers.go |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8f5a67ef99971f60961e6ba26c51cf7d41f72889 |
| --- /dev/null |
| +++ b/go/src/infra/tricium/service/default/handlers.go |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Package handlers implements HTTP handlers for the default module. |
| +package handlers |
| + |
| +import ( |
| + "html/template" |
| + "net/http" |
| + |
| + "google.golang.org/appengine" |
| + "google.golang.org/appengine/taskqueue" |
| +) |
| + |
| +func init() { |
| + http.HandleFunc("/", landingPageHandler) |
| + http.HandleFunc("/analyze", analyzeHandler) |
| +} |
| + |
| +var basePage = template.Must(template.ParseFiles("templates/base.html")) |
| + |
| +func landingPageHandler(w http.ResponseWriter, r *http.Request) { |
| + data := map[string]interface{}{ |
| + "Msg": "This service is under construction ...", |
| + "ShowRequestForm": true, |
| + } |
| + basePage.Execute(w, data) |
|
nodir
2016/07/12 17:10:38
drive by: the returned error is silently ignored.
emso
2016/07/14 06:48:42
Yes, added a fix for this in https://codereview.ch
|
| +} |
| + |
| +func analyzeHandler(w http.ResponseWriter, r *http.Request) { |
| + ctx := appengine.NewContext(r) |
| + t := taskqueue.NewPOSTTask("/workflow-launcher/queue-handler", map[string][]string{"name": {"Analyze Request"}}) |
| + if _, err := taskqueue.Add(ctx, t, "workflow-launcher-queue"); err != nil { |
| + http.Error(w, err.Error(), http.StatusInternalServerError) |
| + return |
| + } |
| + data := map[string]interface{}{ |
| + "Msg": "Dummy analysis request sent.", |
| + } |
| + basePage.Execute(w, data) |
| +} |