fix(all)
This commit is contained in:
+8
-3
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user