-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
112 lines (90 loc) · 2.69 KB
/
main.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package main
import (
"embed"
"html/template"
"io/fs"
"log"
"net/http"
)
//go:embed static
var static embed.FS
//go:embed templates
var templates embed.FS
func main() {
log.Println("Manage my money...")
s, err := fs.Sub(static, "static")
if err != nil {
panic("Could not open the static directory.")
}
t, err := fs.Sub(templates, "templates")
if err != nil {
panic("Could not open the templates directory.")
}
http.HandleFunc("/manage-my-money/static/styles.css",
func(w http.ResponseWriter, r *http.Request) {
http.ServeFileFS(w, r, s, "styles.css")
})
http.HandleFunc("/manage-my-money", func(w http.ResponseWriter,
r *http.Request) {
log.Println("Loading the main page.")
tmpl := template.Must(template.ParseFS(t, "index.html"))
tmpl.Execute(w, nil)
})
http.HandleFunc(SummariesRoute,
func(w http.ResponseWriter, r *http.Request) {
GetSummaries(w, r, &t)
})
http.HandleFunc(UpdateSummaryRoute,
func(w http.ResponseWriter, r *http.Request) {
UpdateSummary(w, r, &t)
})
http.HandleFunc(CategorizeTransactionPgRoute,
func(w http.ResponseWriter, r *http.Request) {
CategorizeTransactionPage(w, r, &t)
})
http.HandleFunc(TransactionsUploadRoute,
func(w http.ResponseWriter, r *http.Request) {
UploadFile(w, r, &t)
})
http.HandleFunc(CustomizeCategoriesPageRoute,
func(w http.ResponseWriter, r *http.Request) {
CustomizeCategoriesPage(w, r, &t)
})
http.HandleFunc(GetTransactionsRoute,
func(w http.ResponseWriter, r *http.Request) {
GetTransactions(w, r, &t)
})
http.HandleFunc(EditTransactionsRoute,
func(w http.ResponseWriter, r *http.Request) {
EditTransactions(w, r, &t)
})
http.HandleFunc(ReadTransactionsButtonRoute,
func(w http.ResponseWriter, r *http.Request) {
ReadTransactionsButton(w, r, &t)
})
http.HandleFunc(EditTransactionsButtonRoute,
func(w http.ResponseWriter, r *http.Request) {
EditTransactionsButton(w, r, &t)
})
http.HandleFunc(UpdateTransactionRoute,
func(w http.ResponseWriter, r *http.Request) {
UpdateTransaction(w, r, &t)
})
http.HandleFunc(EditCategoriesRoute,
func(w http.ResponseWriter, r *http.Request) {
EditCategories(w, r, &t)
})
http.HandleFunc(DeleteCategoriesRoute,
func(w http.ResponseWriter, r *http.Request) {
DeleteCategory(w, r, &t)
})
http.HandleFunc(ReadCategoriesRoute,
func(w http.ResponseWriter, r *http.Request) {
GetCategories(w, r, &t)
})
http.HandleFunc(AddCategoriesRoute,
func(w http.ResponseWriter, r *http.Request) {
AddCategory(w, r, &t)
})
log.Fatalln(http.ListenAndServe(":8082", nil))
}