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

Unified Diff: go/src/infra/tricium/service/default/handler.go

Issue 2125603002: Adds initial Tricium service GAE configs (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 side-by-side diff with in-line comments
Download patch
Index: go/src/infra/tricium/service/default/handler.go
diff --git a/go/src/infra/tricium/service/default/handler.go b/go/src/infra/tricium/service/default/handler.go
new file mode 100644
index 0000000000000000000000000000000000000000..3bdc6143882da785d64272910cd04dc1856e0c8f
--- /dev/null
+++ b/go/src/infra/tricium/service/default/handler.go
@@ -0,0 +1,59 @@
+package handlers
+
+import (
+ "fmt"
+ "net/http"
+
+ "appengine"
+ "appengine/taskqueue"
+)
+
+func init() {
+ http.HandleFunc("/", landingPageHandler)
+ http.HandleFunc("/analyze", analyzeHandler)
+}
+
+var landingPage = `
Paweł Hajdan Jr. 2016/07/05 12:16:00 Please consider using https://golang.org/pkg/html/
emso 2016/07/06 06:21:28 Done. Thanks, much better.
+<html>
+<head><title>Tricium</title></head>
+<body>
+<font face="sans-serif">
+== T R I C I U M ==
+<hr size="1">
+<p>This service is under construction ...</p>
+<hr size="1">
+<form action="/analyze" method="post">
+ <div><input type="submit" value="Dummy Analysis Request"></div>
+</form>
+</body>
+</html>`
+
+var analysisRequestedPage = `
+<html>
+<head><title>Tricium</title></head>
+<body>
+<font face="sans-serif">
+== T R I C I U M ==
+<hr size="1">
+Analysis request enqueued.
+<hr size="1">
+Back to the <a href="/">landing page</a>.
+</form>
+</font>
+</body>
+</html>
+`
+
+func landingPageHandler(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprint(w, landingPage)
+}
+
+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"}})
Paweł Hajdan Jr. 2016/07/05 12:16:00 Please consider using https://cloud.google.com/app
emso 2016/07/06 06:21:28 I have considered this alternative and don't think
+ if _, err := taskqueue.Add(ctx, t, "workflow-launcher-queue"); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ fmt.Fprint(w, analysisRequestedPage)
+}

Powered by Google App Engine
This is Rietveld 408576698