| 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 "ShowRequestForm": true, |
| 22 } |
| 23 basePage.Execute(w, data) |
| 24 } |
| 25 |
| 26 func analyzeHandler(w http.ResponseWriter, r *http.Request) { |
| 27 ctx := appengine.NewContext(r) |
| 28 t := taskqueue.NewPOSTTask("/workflow-launcher/queue-handler", map[strin
g][]string{"name": {"Analyze Request"}}) |
| 29 if _, err := taskqueue.Add(ctx, t, "workflow-launcher-queue"); err != ni
l { |
| 30 http.Error(w, err.Error(), http.StatusInternalServerError) |
| 31 return |
| 32 } |
| 33 data := map[string]interface{}{ |
| 34 "Msg": "Dummy analysis request sent.", |
| 35 } |
| 36 basePage.Execute(w, data) |
| 37 } |
| OLD | NEW |