Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
boozec committed Apr 7, 2024
1 parent dc2aa3e commit fc0235d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This repo refers to the Airline service used by ACME Sky.

It is a REST API backend used by ACME Sky to find new flights and receive new
offerts.
offers.

## Build

Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func main() {
hooks.POST("/", handlers.HookHandlerPost)
hooks.GET("/:id/", handlers.HookHandlerGetId)
hooks.PUT("/:id/", handlers.HookHandlerPut)
hooks.POST("/offert/", handlers.HookHandlerOffert)
hooks.POST("/offer/", handlers.HookHandlerOffer)
}
}

Expand Down
8 changes: 4 additions & 4 deletions internal/handlers/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ func HookHandlerPut(c *gin.Context) {
c.JSON(http.StatusOK, hook)
}

// Handle POST request to send an offert to all the saved hooks.
// Handle POST request to send an offer to all the saved hooks.
// First get all hooks, then validate the request payload which must be
// `{"flight_id": <valid_id>}`
// and finally send the flight object to all the hooks by their endpoint.
func HookHandlerOffert(c *gin.Context) {
func HookHandlerOffer(c *gin.Context) {
db, _ := db.GetDb()

var hooks []models.Hook
db.Find(&hooks)

var input models.OffertInput
var input models.OfferInput
if err := c.ShouldBindJSON(&input); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"message": err.Error()})
return
Expand Down Expand Up @@ -136,7 +136,7 @@ func HookHandlerOffert(c *gin.Context) {
total += 1
}

// Send back some info just to know how many hook work or not
// Send back some info just to know how many hook work or not
c.JSON(http.StatusOK, gin.H{
"hooks": len(hooks),
"sent": total,
Expand Down
2 changes: 1 addition & 1 deletion internal/models/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type HookInput struct {
}

// Struct used to send a new request for a selected flight
type OffertInput struct {
type OfferInput struct {
FlightId int `json:"flight_id" binding:"required"`
}

Expand Down

0 comments on commit fc0235d

Please sign in to comment.