-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
33 lines (29 loc) · 892 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
package main
import (
"go-gin-auth/controllers"
"go-gin-auth/initializers"
"go-gin-auth/middleware"
"net/http"
"github.com/gin-gonic/gin"
)
func init() {
initializers.LoadEnvVariables()
initializers.ConnectToDb()
initializers.SyncDatabase()
}
// consider putting routes in a different file subsequently, to mave the code cleaner
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.String(http.StatusOK, "Hello darkness my old friend!")
})
r.POST("/signup", controllers.Signup)
r.POST("/login", controllers.Login)
r.GET("/user", middleware.VerifyToken, controllers.User)
r.POST("/forgot-password", controllers.ForgotPassword)
r.POST("/verify-otp", controllers.VerifyOtp)
r.POST("/reset-password", controllers.ResetPassword)
r.GET("/users", controllers.FetchUsers)
r.GET("/todos", controllers.FetchTodos)
r.Run() // listen and serve on 0.0.0.0:3000
}