forked from GoesToEleven/GolangTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (51 loc) · 1.46 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"net/http"
)
type User struct {
Email string
UserName string `datastore:"-"`
Password string `json:"-"`
}
var tpl *template.Template
func init() {
r := httprouter.New()
http.Handle("/", r)
r.GET("/", Home)
r.GET("/form/login", Login)
r.GET("/form/signup", Signup)
r.POST("/api/checkusername", checkUserName)
r.POST("/api/createuser", createUser)
http.Handle("/favicon.ico", http.NotFoundHandler())
http.Handle("/public/", http.StripPrefix("/public", http.FileServer(http.Dir("public/"))))
tpl = template.Must(template.ParseGlob("templates/html/*.html"))
}
func Home(res http.ResponseWriter, req *http.Request, _ httprouter.Params) {
memTemplate(res, req, "Homepage", "home.html")
}
func Login(res http.ResponseWriter, req *http.Request, _ httprouter.Params) {
memTemplate(res, req, "Loginpage", "login.html")
}
func Signup(res http.ResponseWriter, req *http.Request, _ httprouter.Params) {
memTemplate(res, req, "Signuppage", "signup.html")
}
/*
TO DO:
session
-memcache templates
- uuid in a cookie
--- https while logged in? - depends upon security required
- encrypt password on datastore?
--- never store an unencrypted password, so, resoundingly, YES
--- sha-256 fast hash value
- user memcache?
- datastore / memcache
session interface change
- change login button to logout when user logged in
post tweets
follow people
see tweets for everyone
see tweets for individual user
*/