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.
Files
cover-letter-templater/backend/routes/routes.go
T

41 lines
854 B
Go
Raw Normal View History

2025-07-03 17:55:15 +03:00
package routes
import (
"backend/controllers/cover"
2025-07-09 23:19:31 +03:00
"backend/controllers/template"
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
// Guest routes (Register, Login)
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())
2025-07-09 23:19:31 +03:00
// Route to check if user is authenticated
auth.GET("/info", user.TokenInfo)
// Template routes (REST FUCKING GOOOOO)
templates := auth.Group("/templates")
templates.GET("", template.Get)
2025-07-09 23:19:31 +03:00
templates.POST("", template.Create)
// PUT (Edit)
// DELETE (Delete)
2025-07-06 18:13:26 +03:00
// Cover letter routes
covers := auth.Group("/cover")
2025-07-12 16:38:40 +03:00
covers.GET("", cover.Get)
covers.GET("/:id", cover.GetID)
covers.POST("", cover.Post)
2025-07-03 17:55:15 +03:00
return r
}