organize routes into route groups, add comments

This commit is contained in:
katefort 2025-04-23 16:29:01 -05:00
parent 34218e7306
commit 57dce10097
2 changed files with 7 additions and 2 deletions

View file

@ -10,8 +10,11 @@ func (application *Application) bindRoutes() {
router.GET("/", application.TestHandler)
router.GET("/claims/:system/:barcode", application.GetClaimsHandler)
router.POST("/claims/:system/:barcode", application.PostClaimHandler)
claims := router.Group("/claims/:system/:barcode")
{
claims.GET("", application.GetClaimsHandler)
claims.POST("", application.PostClaimHandler)
}
router.Run("localhost:8080")
}

View file

@ -6,6 +6,8 @@ import (
"vegan-barcode/internal/models"
)
// GetClaims doesn't automatically create a new product because maybe the user mistyped.
// Only create a new product when they want to add claims.
func (a *Application) GetClaims(system string, barcode string) (*models.ProductClaims, error) {
product, err := a.db.FindProductByBarcode(system, barcode)
if err != nil {