-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (29 loc) · 717 Bytes
/
main.go
File metadata and controls
37 lines (29 loc) · 717 Bytes
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
package main
import (
"github.com/gorilla/mux"
"net/http"
"os"
"pcpartpicker-api/api/endpoints"
"pcpartpicker-api/cache/sync"
"pcpartpicker-api/scraper"
)
func init() {
go sync.Sync()
}
func getPort() string {
p := os.Getenv("PORT")
if p != "" {
return ":" + p
}
return ":6920"
}
func main() {
defer scraper.Instance.Quit()
defer scraper.Service.Stop()
router := mux.NewRouter()
router.HandleFunc("/guides", endpoints.GetBuildGuides).Methods("GET")
router.HandleFunc("/gdetails", endpoints.GetGuideDetails)
router.HandleFunc("/parts", endpoints.GetPartsList)
router.HandleFunc("/completedBuilds", endpoints.GetCompletedBuilds).Methods("POST")
_ = http.ListenAndServe(getPort(), router)
}