-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
36 lines (29 loc) · 981 Bytes
/
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
/*
An tutorial image sharing platform built with Go, Redis, UIkit and good intentions.
Copyright (c) 2015, Luca Chiricozzi. All rights reserved.
Released under the MIT License.
http://opensource.org/licenses/MIT
*/
package main
import (
"flag"
"log"
"net/http"
"path/filepath"
)
func main() {
// Create a new Redis pool
flag.Parse()
pool = newPool(*redisServer)
http.Handle("/", appHandler(handleRoot))
http.Handle("/register", appHandler(handleRegister))
http.Handle("/registration", redisHandler(handleRegistration))
http.Handle("/login", redisHandler(handleLogin))
http.HandleFunc("/logout", handleLogout)
http.Handle("/post", redisHandler(handlePost))
media := http.FileServer(http.Dir(filepath.Join(mediaPath...)))
http.Handle("/media/", http.StripPrefix("/media/", media))
static := http.FileServer(http.Dir(filepath.Join(staticPath...)))
http.Handle("/static/", http.StripPrefix("/static/", static))
log.Fatalln(http.ListenAndServe(":8080", nil))
}