-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (30 loc) · 835 Bytes
/
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
package main
import (
"api-services/controllers"
"api-services/initializers"
"api-services/middleware"
"github.com/gin-gonic/gin"
)
func init() {
initializers.LoadEnv() // please your check .env
// initializers.Connection() // please check your connection database or comment if your not use db
}
func main() {
router := gin.Default() //gin router initialization
// route to web
router.LoadHTMLGlob("templates/*")
router.GET("/", controllers.Web)
// route to api
api := router.Group("/api")
{
// route without middleware
api.POST("/sign-up", controllers.Register)
api.POST("/sign-in", controllers.Login)
// route with middleware
api.Use(middleware.MiddlewareApi)
api.GET("/", controllers.Services)
// route request api example
api.GET("/get-response", controllers.GetResponse)
}
router.Run()
}