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("POST /api/bookmakers", postBookmakers)
19
20 http.HandleFunc("GET /api/accounts", getAccounts)
21 http.HandleFunc("POST /api/accounts", postAccounts)
22
23 http.HandleFunc("GET /api/records", getRecords)
24 http.HandleFunc("POST /api/records", postRecords)
25
26 log.Println("Serving at " + address + "...")
27 log.Fatal(http.ListenAndServe(address, nil))
28}