-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (33 loc) · 1.16 KB
/
main.go
File metadata and controls
42 lines (33 loc) · 1.16 KB
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
package main
import (
"net/http"
"time"
"webchat/handlers"
"webchat/utils"
)
func main() {
utils.P("WebChat", utils.Version(), "started at", utils.Config.Address)
mux := http.NewServeMux()
files := http.FileServer(http.Dir(utils.Config.Static))
mux.Handle("/static/", http.StripPrefix("/static/", files))
// handlers funcs
mux.HandleFunc("/", handlers.Index)
mux.HandleFunc("/err", handlers.Err)
mux.HandleFunc("/login", handlers.Login)
mux.HandleFunc("/logout", handlers.Logout)
mux.HandleFunc("/signup", handlers.Signup)
mux.HandleFunc("/signup_account", handlers.SignupAccount)
mux.HandleFunc("/authenticate", handlers.Authenticate)
mux.HandleFunc("/thread/new", handlers.NewThread)
mux.HandleFunc("/thread/create", handlers.CreateThread)
mux.HandleFunc("/thread/post", handlers.PostThread)
mux.HandleFunc("/thread/read", handlers.ReadThread)
server := &http.Server{
Addr: utils.Config.Address,
Handler: mux,
ReadTimeout: time.Duration(utils.Config.ReadTimeout * int64(time.Second)),
WriteTimeout: time.Duration(utils.Config.WriteTimeout * int64(time.Second)),
MaxHeaderBytes: 1 << 20,
}
_ = server.ListenAndServe()
}