Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hello
- import (
- "appengine"
- "appengine/user"
- "http"
- "template"
- )
- var baseTemplate = template.MustParseFile("base.html", nil)
- func init() {
- http.HandleFunc("/", 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
- }
- baseTemplate.Execute(w, u)
- }
Add Comment
Please, Sign In to add comment