Skip to content

Commit

Permalink
Use status no content when needed (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
polldo authored May 20, 2023
1 parent 82f2a71 commit 66a5a8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/auth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func HandleLogin(db *sqlx.DB, session *scs.SessionManager) web.Handler {
return err
}

return web.Respond(ctx, w, nil, http.StatusOK)
return web.Respond(ctx, w, nil, http.StatusNoContent)
}
}

Expand Down Expand Up @@ -161,7 +161,7 @@ func HandleOauthCallback(db *sqlx.DB, session *scs.SessionManager, provs map[str
return err
}

return web.Respond(ctx, w, nil, http.StatusOK)
return web.Respond(ctx, w, nil, http.StatusNoContent)
}
}

Expand Down
8 changes: 4 additions & 4 deletions core/order/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func HandlePaypalCapture(db *sqlx.DB, pp *paypal.Client) web.Handler {
return fmt.Errorf("the order was payed but its fulfillment failed: %w", err)
}

return web.Respond(ctx, w, nil, http.StatusOK)
return web.Respond(ctx, w, nil, http.StatusNoContent)
}
}

Expand Down Expand Up @@ -294,7 +294,7 @@ func HandleStripeCapture(db *sqlx.DB, cfg config.Stripe) web.Handler {

// Filter all the events but the checkout completion one.
if event.Type != "checkout.session.completed" {
return web.Respond(ctx, w, nil, http.StatusOK)
return web.Respond(ctx, w, nil, http.StatusNoContent)
}

var session stripe.CheckoutSession
Expand All @@ -305,13 +305,13 @@ func HandleStripeCapture(db *sqlx.DB, cfg config.Stripe) web.Handler {

// Filter out checkouts that are not for one-time payments.
if session.Mode != stripe.CheckoutSessionModePayment {
return web.Respond(ctx, w, nil, http.StatusOK)
return web.Respond(ctx, w, nil, http.StatusNoContent)
}

if err := fulfill(ctx, db, session.ID); err != nil {
return fmt.Errorf("the order was payed but its fulfillment failed: %w", err)
}

return web.Respond(ctx, w, nil, http.StatusOK)
return web.Respond(ctx, w, nil, http.StatusNoContent)
}
}

0 comments on commit 66a5a8c

Please sign in to comment.