| OLD | NEW |
| (Empty) | |
| 1 package handlers |
| 2 |
| 3 import ( |
| 4 "html/template" |
| 5 "net/http" |
| 6 |
| 7 "appengine" |
| 8 "appengine/taskqueue" |
| 9 ) |
| 10 |
| 11 func init() { |
| 12 http.HandleFunc("/", landingPageHandler) |
| 13 http.HandleFunc("/analyze", analyzeHandler) |
| 14 } |
| 15 |
| 16 var basePage = template.Must(template.ParseFiles("templates/base.html")) |
| 17 |
| 18 func landingPageHandler(w http.ResponseWriter, r *http.Request) { |
| 19 data := map[string]interface{}{ |
| 20 "Msg": "This service is under construction ...", |
| 21 } |
| 22 basePage.Execute(w, data) |
| 23 } |
| 24 |
| 25 func analyzeHandler(w http.ResponseWriter, r *http.Request) { |
| 26 ctx := appengine.NewContext(r) |
| 27 t := taskqueue.NewPOSTTask("/workflow-launcher/queue-handler", map[strin
g][]string{"name": {"Analyze Request"}}) |
| 28 if _, err := taskqueue.Add(ctx, t, "workflow-launcher-queue"); err != ni
l { |
| 29 http.Error(w, err.Error(), http.StatusInternalServerError) |
| 30 return |
| 31 } |
| 32 data := map[string]interface{}{ |
| 33 "Msg": "Dummy analysis request sent.", |
| 34 } |
| 35 basePage.Execute(w, data) |
| 36 } |
| OLD | NEW |