Skip to content

Commit

Permalink
fix: change variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
webhookx-x committed Aug 24, 2024
1 parent 45c6e72 commit 22d0c5c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions admin/api/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func (api *API) PageSource(w http.ResponseWriter, r *http.Request) {

func (api *API) GetSource(w http.ResponseWriter, r *http.Request) {
id := api.param(r, "id")
endpoint, err := api.DB.SourcesWS.Get(r.Context(), id)
source, err := api.DB.SourcesWS.Get(r.Context(), id)
api.assert(err)

if endpoint == nil {
if source == nil {
api.json(404, w, ErrorResponse{Message: MsgNotFound})
return
}

api.json(200, w, endpoint)
api.json(200, w, source)
}

func (api *API) CreateSource(w http.ResponseWriter, r *http.Request) {
Expand All @@ -55,28 +55,28 @@ func (api *API) CreateSource(w http.ResponseWriter, r *http.Request) {

func (api *API) UpdateSource(w http.ResponseWriter, r *http.Request) {
id := api.param(r, "id")
endpoint, err := api.DB.SourcesWS.Get(r.Context(), id)
source, err := api.DB.SourcesWS.Get(r.Context(), id)
api.assert(err)
if endpoint == nil {
if source == nil {
api.json(404, w, ErrorResponse{Message: MsgNotFound})
return
}

if err := json.NewDecoder(r.Body).Decode(endpoint); err != nil {
if err := json.NewDecoder(r.Body).Decode(source); err != nil {
api.error(400, w, err)
return
}

if err := endpoint.Validate(); err != nil {
if err := source.Validate(); err != nil {
api.error(400, w, err)
return
}

endpoint.ID = id
err = api.DB.SourcesWS.Update(r.Context(), endpoint)
source.ID = id
err = api.DB.SourcesWS.Update(r.Context(), source)
api.assert(err)

api.json(200, w, endpoint)
api.json(200, w, source)
}

func (api *API) DeleteSource(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 22d0c5c

Please sign in to comment.