-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
58 lines (50 loc) · 1.93 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
package main
import (
"fmt"
"net/http"
"os"
"github.com/muslimilmiawan/ssinventory/controller"
_ "github.com/mattn/go-sqlite3"
"github.com/muslimilmiawan/ssinventory/api"
)
func main() {
http.HandleFunc("/", index)
// inventory routing
http.HandleFunc("/inventory", controller.GetInventory)
http.HandleFunc("/inventory/list", controller.ListInventory)
http.HandleFunc("/inventory/add", controller.AddInventory)
http.HandleFunc("/inventory/addBulk", controller.AddBulkInventory)
http.HandleFunc("/inventory/update", controller.UpdateInventory)
http.HandleFunc("/inventory/delete", controller.DeleteInventoryController)
http.HandleFunc("/inventory/readfile", controller.MigrateInventoryFromFile)
// purchasing routing
http.HandleFunc("/purchasing", controller.GetPurchase)
http.HandleFunc("/purchasing/list", controller.ListPurchase)
http.HandleFunc("/purchasing/add", controller.AddPurchase)
http.HandleFunc("/purchasing/addBulk", controller.AddBulkPurchase)
http.HandleFunc("/purchasing/update", controller.UpdatePurchase)
http.HandleFunc("/purchasing/delete", controller.DeletePurchase)
// sales routing
http.HandleFunc("/sales", controller.GetSales)
http.HandleFunc("/sales/list", controller.ListSales)
http.HandleFunc("/sales/add", controller.AddSales)
http.HandleFunc("/sales/addBulk", controller.AddBulkSales)
http.HandleFunc("/sales/update", controller.UpdateSales)
http.HandleFunc("/sales/delete", controller.DeleteSales)
// report routing
http.HandleFunc("/report/inventory", controller.GenerateInventoryReport)
http.HandleFunc("/report/sales", controller.GenerateSalesReport)
http.HandleFunc("/createTables", api.CreateTables)
http.ListenAndServe(port(), nil)
}
func port() string {
port := os.Getenv("PORT")
if len(port) == 0 {
port = "8080"
}
return ":" + port
}
func index(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Hi, There this is Muslim's Sale Stock Code test")
}