all repos — piggy @ bbb48c59b31feefe1c469fb20c41527184610062

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("GET /api/bookmakers/{id}", getBookmakersId)
19	http.HandleFunc("POST /api/bookmakers", postBookmakers)
20	http.HandleFunc("DELETE /api/bookmakers/{id}", deleteBookmakersId)
21
22	http.HandleFunc("GET /api/accounts", getAccounts)
23	http.HandleFunc("GET /api/accounts/{id}", getAccountsId)
24	http.HandleFunc("POST /api/accounts", postAccounts)
25	http.HandleFunc("DELETE /api/accounts/{id}", deleteAccountsId)
26
27	http.HandleFunc("GET /api/records", getRecords)
28	http.HandleFunc("GET /api/records/{id}", getRecordsId)
29	http.HandleFunc("POST /api/records", postRecords)
30	http.HandleFunc("DELETE /api/records/{id}", deleteRecordsId)
31
32	log.Println("Serving at " + address + "...")
33	log.Fatal(http.ListenAndServe(address, nil))
34}