-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (32 loc) · 1.21 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
package main
import (
"github.com/dannielss/goflix/controllers"
"github.com/dannielss/goflix/database"
"github.com/dannielss/goflix/middlewares"
"github.com/dannielss/goflix/repositories"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
)
func main() {
conn := database.NewMySQLClient()
defer conn.Close()
userRepo := repositories.NewUserRepository(conn)
userController := controllers.NewUserController(userRepo)
loginController := controllers.NewLoginController(userRepo)
categoryRepo := repositories.NewCategoryRepository(conn)
categoryController := controllers.NewCategoryController(categoryRepo)
movieRepo := repositories.NewMovieRepository(conn)
movieController := controllers.NewMovieController(movieRepo)
r := gin.Default()
r.POST("/login", loginController.Login)
r.POST("/user", userController.AddUser)
r.Use(middlewares.Auth())
r.GET("/users", userController.ShowUsers)
r.PUT("/user/:id", userController.UpdateUser)
r.DELETE("/user/:id", userController.DeleteUser)
r.GET("/categories", categoryController.ShowCategories)
r.POST("/category", categoryController.AddCategory)
r.GET("/movies", movieController.ShowMovies)
r.POST("/movie", movieController.AddMovie)
r.Run(":3333")
}