src/api/routes.go (view raw)
1package api
2
3import (
4 "log"
5 "net/http"
6
7 "github.com/BiRabittoh/piggy/src/app"
8)
9
10const address = ":3000"
11
12func ListenAndServe() {
13 app.InitDB()
14
15 http.Handle("GET /", http.FileServer(http.Dir("static")))
16
17 http.HandleFunc("GET /api/bookmakers", getBookmakers)
18 http.HandleFunc("GET /api/bookmakers/{id}", getBookmakersId)
19 http.HandleFunc("POST /api/bookmakers", postBookmakers)
20
21 http.HandleFunc("GET /api/accounts", getAccounts)
22 http.HandleFunc("GET /api/accounts/{id}", getAccountsId)
23 http.HandleFunc("POST /api/accounts", postAccounts)
24
25 http.HandleFunc("GET /api/records", getRecords)
26 http.HandleFunc("GET /api/records/{id}", getRecordsId)
27 http.HandleFunc("POST /api/records", postRecords)
28
29 log.Println("Serving at " + address + "...")
30 log.Fatal(http.ListenAndServe(address, nil))
31}