all repos — piggy @ 8a31a262f27c077d8a41170129e08c147f5404b9

Dead simple finance manager in Go, HTML and JS.

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("GET /api/records/{id}", getRecordsId)
25	http.HandleFunc("POST /api/records", postRecords)
26
27	log.Println("Serving at " + address + "...")
28	log.Fatal(http.ListenAndServe(address, nil))
29}