-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (33 loc) · 1.16 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
package main
import (
"github.com/ockibagusp/hello/db"
t "github.com/ockibagusp/hello/template"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
c "github.com/ockibagusp/hello/controllers"
)
func main() {
db.Init()
// Echo instance
e := echo.New()
// Middleware
e.Use(middleware.Logger())
e.Use(middleware.Recover())
// Instantiate a template registry with an array of template set
e.Renderer = t.Templates()
// // Why bootstrap.min.css, bootstrap.min.js, jquery.min.js?
e.Static("/assets", "assets")
// controllers init
controllers := c.Controller{DB: db.DbManager()}
// Route => controllers
e.GET("/", controllers.Home).Name = "home"
e.GET("/about", controllers.About).Name = "about"
e.GET("/users", controllers.Users).Name = "users"
e.GET("/users/add", controllers.CreateUser).Name = "user/add get"
e.POST("/users/add", controllers.CreateUser).Name = "user/add post"
e.GET("/users/read/:id", controllers.ReadUser).Name = "user/read get"
e.GET("/users/view/:id", controllers.UpdateUser).Name = "user/view get"
e.GET("/users/delete/:id", controllers.DeleteUser).Name = "user/view delete"
// Start the Echo server
e.Start(":8000")
}