-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
29 lines (23 loc) · 893 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
package main
import (
"fmt"
"log"
"net/http"
"go-api/controllers"
"go-api/util"
"go-api/ws"
)
func main() {
fmt.Println("Http server running")
vote := util.NewVotingPubSub()
http.HandleFunc("/", controllers.Home_Controller)
http.HandleFunc("/createPoll", controllers.PollForm_Controller)
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
http.HandleFunc("/polls", controllers.Polls_Controller)
http.HandleFunc("/polls/{pollId}", controllers.Poll_Controller)
http.HandleFunc("/pollsHtml/{pollId}", controllers.PollHtlm_Controller)
http.HandleFunc("/polls/{pollId}/votes", controllers.VotePoll_Controller(vote))
http.HandleFunc("/polls/{pollId}/results", ws.ResultsWebSocketHandler(vote))
fmt.Println("Server is listinig on port http://localhost:3333")
log.Fatal(http.ListenAndServe(":3333", nil))
}