Commits

sweemeng committed 6dd2cf4

with output and login

  • Participants

Comments (0)

Files changed (2)

+application: goproj
+version: 1
+runtime: go
+api_version: 1
+
+handlers:
+- url: /.*
+  script: _go_app

goproj/positions/positions.go

+package positions
+
+import (
+    "appengine"
+    "appengine/user"
+    "fmt"
+    "http"
+)
+
+func init(){
+    http.HandleFunc("/position/",handler)
+}
+
+func handler(w http.ResponseWriter,r *http.Request){
+    c := appengine.NewContext(r)
+    u := user.Current(c)
+    if u == nil{
+        url, err := user.LoginURL(c,r.URL.String())
+        if err != nil{
+            http.Error(w,err.String(),http.StatusInternalServerError)
+            return
+        }
+        w.Header().Set("Location",url)
+        w.WriteHeader(http.StatusFound)
+        return
+    }
+    fmt.Fprint(w,u)
+}