Commit e5542180a21a5fbc75318d3e91557179d778ce58

Authored by David Shere
1 parent f642f621e1

made identifiers consistent and fixed minor formatting issues

Showing 1 changed file with 3 additions and 3 deletions Inline Diff

package webhash 1 1 package webhash
2 2
import ( 3 3 import (
"html/template" 4 4 "html/template"
"net/http" 5 5 "net/http"
6 6
"appengine" 7 7 "appengine"
"appengine/datastore" 8 8 "appengine/datastore"
// "appengine/user" 9 9 //"appengine/user"
) 10 10 )
11 11
func init() { 12 12 func init() {
http.HandleFunc("/", handlerRoot) 13 13 http.HandleFunc("/", rootHandler)
} 14 14 }
15 15
type User struct { 16 16 type User struct {
UserID string 17 17 UserID string
Value string 18 18 Value string
} 19 19 }
20 20
func handlerRoot(w http.ResponseWriter, r *http.Request) { 21 21 func rootHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r) 22 22 c := appengine.NewContext(r)
u := User{ 23 23 u := User{
UserID: r.FormValue("userid"), 24 24 UserID: r.FormValue("userid"),
Value: r.FormValue("value"), 25 25 Value: r.FormValue("value"),
} 26 26 }
k := datastore.NewKey(c, "User", u.UserID, 0, nil) 27 27 k := datastore.NewKey(c, "User", u.UserID, 0, nil)
28 28
if u.Value == "" { 29 29 if u.Value == "" {
datastore.Get(c, k, &u) 30 30 datastore.Get(c, k, &u)
} else { 31 31 } else {
datastore.Put(c, k, &u) 32 32 datastore.Put(c, k, &u)
} 33 33 }
34 34
rootTemplate.Execute(w, u.Value) 35 35 rootTemplate.Execute(w, u.Value)
36 36
} 37 37 }
38 38
var rootTemplate = template.Must(template.New("root").Parse(rootTemplateHTML)) 39 39 var rootTemplate = template.Must(template.New("root").Parse(rootTemplateHTML))
40 40
const rootTemplateHTML = ` 41 41 const rootTemplateHTML = `
<!DOCTYPE HTML> 42 42 <!DOCTYPE HTML>
<html> 43 43 <html>
<head> 44 44 <head>
<title>WebHash Go</title> 45 45 <title>WebHash Go</title>