Skip to content

Instantly share code, notes, and snippets.

@krittawatcode
Last active December 14, 2020 19:08
Show Gist options
  • Save krittawatcode/c405fdef1bdb0c641b450705487dc6b2 to your computer and use it in GitHub Desktop.
Save krittawatcode/c405fdef1bdb0c641b450705487dc6b2 to your computer and use it in GitHub Desktop.
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