This commit is contained in:
2026-06-12 21:50:03 +03:00
parent a0481f74b2
commit a48b417257
6 changed files with 49 additions and 54 deletions
+8 -3
View File
@@ -2,6 +2,7 @@ package main
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
@@ -37,14 +38,14 @@ func main() {
{
api.POST("/login", handlers.Login)
protected := api.Group("/")
api.GET("/items/:id", handlers.GetItem)
api.GET("/items/", handlers.GetAllItems)
api.GET("/getCategories", handlers.GetCategories)
protected.Use(middleware.AuthRequired())
{
protected.GET("/items/:id", handlers.GetItem)
protected.GET("/items/", handlers.GetAllItems)
protected.DELETE("/items/:id", handlers.DeleteItem)
protected.PATCH("/items/:id", handlers.UpdateItem)
protected.POST("/items", handlers.AddItem)
protected.GET("/getCategories", handlers.GetCategories)
}
admin := protected.Group("/")
@@ -54,5 +55,9 @@ func main() {
}
}
r.NoRoute(func(c *gin.Context) {
c.JSON(http.StatusNotFound, gin.H{"status": 404, "message": "API not found"})
})
r.Run(":8081")
}