34 lines
830 B
Go
34 lines
830 B
Go
package router
|
|
|
|
import (
|
|
"memora-api/internal/handler"
|
|
"memora-api/internal/middleware"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func New(wordHandler *handler.WordHandler, authHandler *handler.AuthHandler) *gin.Engine {
|
|
r := gin.Default()
|
|
r.Use(middleware.CORS())
|
|
|
|
api := r.Group("/api")
|
|
{
|
|
api.POST("/auth/register", authHandler.Register)
|
|
api.POST("/auth/login", authHandler.Login)
|
|
api.GET("/auth/me", authHandler.Me)
|
|
|
|
protected := api.Group("")
|
|
protected.Use(middleware.AuthRequired())
|
|
{
|
|
protected.POST("/words", wordHandler.AddWord)
|
|
protected.GET("/words", wordHandler.GetWords)
|
|
protected.GET("/review", wordHandler.GetReviewWords)
|
|
protected.POST("/review", wordHandler.SubmitReview)
|
|
protected.GET("/stats", wordHandler.GetStatistics)
|
|
protected.GET("/audio", wordHandler.GetAudio)
|
|
}
|
|
}
|
|
|
|
return r
|
|
}
|