Chromium Code Reviews| 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) |
| +} |