organize routes into route groups, add comments
This commit is contained in:
parent
34218e7306
commit
57dce10097
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue