This repository has been archived on 2026-01-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2025-07-03 17:55:15 +03:00
|
|
|
package routes
|
|
|
|
|
|
|
|
|
|
import (
|
2025-07-06 16:46:21 +03:00
|
|
|
"backend/controllers/user"
|
2025-07-06 18:13:26 +03:00
|
|
|
"backend/middleware"
|
2025-07-03 17:55:15 +03:00
|
|
|
|
2025-07-03 21:58:49 +03:00
|
|
|
"github.com/gin-gonic/gin"
|
2025-07-03 17:55:15 +03:00
|
|
|
)
|
|
|
|
|
|
2025-07-03 21:58:49 +03:00
|
|
|
func SetupRoutes() *gin.Engine {
|
|
|
|
|
r := gin.Default()
|
2025-07-03 17:55:15 +03:00
|
|
|
|
2025-07-05 21:11:09 +03:00
|
|
|
// Guest routes (Register, Login, check auth)
|
2025-07-06 16:46:21 +03:00
|
|
|
r.POST("/register", user.Register)
|
|
|
|
|
r.POST("/login", user.Login)
|
2025-07-03 17:55:15 +03:00
|
|
|
|
2025-07-06 18:13:26 +03:00
|
|
|
// Authenticated routes middleware/group
|
|
|
|
|
auth := r.Group("/")
|
|
|
|
|
auth.Use(middleware.IsAuthenticated())
|
|
|
|
|
|
|
|
|
|
auth.GET("/info", user.TokenInfo) // Route to check if user is authenticated
|
|
|
|
|
|
2025-07-03 17:55:15 +03:00
|
|
|
return r
|
|
|
|
|
}
|