mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
fix(onboarding): could not create user (#848)
fix: onboarding not working
This commit is contained in:
parent
d03561d61c
commit
7f05dd1efd
16 changed files with 182 additions and 130 deletions
|
@ -44,7 +44,7 @@ func (h actionHandler) getActions(w http.ResponseWriter, r *http.Request) {
|
|||
// encode error
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(r.Context(), w, actions, http.StatusOK)
|
||||
h.encoder.StatusResponse(w, http.StatusOK, actions)
|
||||
}
|
||||
|
||||
func (h actionHandler) storeAction(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -63,7 +63,7 @@ func (h actionHandler) storeAction(w http.ResponseWriter, r *http.Request) {
|
|||
// encode error
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(ctx, w, action, http.StatusCreated)
|
||||
h.encoder.StatusResponse(w, http.StatusCreated, action)
|
||||
}
|
||||
|
||||
func (h actionHandler) updateAction(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -82,37 +82,33 @@ func (h actionHandler) updateAction(w http.ResponseWriter, r *http.Request) {
|
|||
// encode error
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(ctx, w, action, http.StatusCreated)
|
||||
h.encoder.StatusResponse(w, http.StatusCreated, action)
|
||||
}
|
||||
|
||||
func (h actionHandler) deleteAction(w http.ResponseWriter, r *http.Request) {
|
||||
var ctx = r.Context()
|
||||
|
||||
actionID, err := parseInt(chi.URLParam(r, "id"))
|
||||
if err != nil {
|
||||
h.encoder.StatusResponse(ctx, w, errors.New("bad param id"), http.StatusBadRequest)
|
||||
h.encoder.StatusResponse(w, http.StatusBadRequest, errors.New("bad param id"))
|
||||
}
|
||||
|
||||
if err := h.service.Delete(actionID); err != nil {
|
||||
// encode error
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(ctx, w, nil, http.StatusNoContent)
|
||||
h.encoder.StatusResponse(w, http.StatusNoContent, nil)
|
||||
}
|
||||
|
||||
func (h actionHandler) toggleActionEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
var ctx = r.Context()
|
||||
|
||||
actionID, err := parseInt(chi.URLParam(r, "id"))
|
||||
if err != nil {
|
||||
h.encoder.StatusResponse(ctx, w, errors.New("bad param id"), http.StatusBadRequest)
|
||||
h.encoder.StatusResponse(w, http.StatusBadRequest, errors.New("bad param id"))
|
||||
}
|
||||
|
||||
if err := h.service.ToggleEnabled(actionID); err != nil {
|
||||
// encode error
|
||||
}
|
||||
|
||||
h.encoder.StatusResponse(ctx, w, nil, http.StatusCreated)
|
||||
h.encoder.StatusResponse(w, http.StatusCreated, nil)
|
||||
}
|
||||
|
||||
func parseInt(s string) (int, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue