-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
36 lines (30 loc) · 1 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
package main
import (
"go-web-native/config"
"go-web-native/controllers/categorycontroller"
"go-web-native/controllers/homecontroller"
"go-web-native/controllers/productcontroller"
"log"
"net/http"
)
func main() {
// Database connection
config.ConnectDB()
// Routes
// 1.Homepage
http.HandleFunc("/", homecontroller.Welcome)
// 2. Category
http.HandleFunc("/categories", categorycontroller.Index)
http.HandleFunc("/categories/add", categorycontroller.Add)
http.HandleFunc("/categories/edit", categorycontroller.Edit)
http.HandleFunc("/categories/delete", categorycontroller.Delete)
// 3. Products
http.HandleFunc("/products", productcontroller.Index)
http.HandleFunc("/products/add", productcontroller.Add)
http.HandleFunc("/products/detail", productcontroller.Detail)
http.HandleFunc("/products/edit", productcontroller.Edit)
http.HandleFunc("/products/delete", productcontroller.Delete)
// Run server
log.Println("Server running on port: 8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}