Last active
December 14, 2020 19:08
-
-
Save krittawatcode/c405fdef1bdb0c641b450705487dc6b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package routes | |
import ( | |
"github.com/gin-gonic/gin" | |
"github.com/krittawatcode/go-todo-clean-arch/databases" | |
"github.com/krittawatcode/go-todo-clean-arch/deliveries" | |
"github.com/krittawatcode/go-todo-clean-arch/repositories" | |
"github.com/krittawatcode/go-todo-clean-arch/usecases" | |
) | |
// SetupRouter ... | |
func SetupRouter() *gin.Engine { | |
todoRepo := repositories.NewToDoRepository(databases.DB) | |
todoUseCase := usecases.NewToDoUseCase(todoRepo) | |
todoHandler := deliveries.NewToDoHandler(todoUseCase) | |
r := gin.Default() | |
v1 := r.Group("/v1") | |
{ | |
v1.GET("todo", todoHandler.GetAllTodo) | |
v1.POST("todo", todoHandler.CreateATodo) | |
v1.GET("todo/:id", todoHandler.GetATodo) | |
v1.PUT("todo/:id", todoHandler.UpdateATodo) | |
v1.DELETE("todo/:id", todoHandler.DeleteATodo) | |
} | |
return r | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment