Add get followers

This commit is contained in:
Marco Realacci 2022-11-18 18:58:12 +01:00
parent b89296c249
commit e8047c77a0
10 changed files with 162 additions and 17 deletions

View file

@ -1,11 +1,11 @@
package api
import (
"encoding/json"
"net/http"
"github.com/julienschmidt/httprouter"
"github.com/notherealmarco/WASAPhoto/service/api/authorization"
"github.com/notherealmarco/WASAPhoto/service/api/helpers"
"github.com/notherealmarco/WASAPhoto/service/api/reqcontext"
"github.com/notherealmarco/WASAPhoto/service/structures"
)
@ -17,14 +17,18 @@ func (rt *_router) UpdateUsername(w http.ResponseWriter, r *http.Request, ps htt
return
}
var req structures.UserDetails
err := json.NewDecoder(r.Body).Decode(&req) //todo: capire se serve close
if err != nil {
w.WriteHeader(http.StatusBadRequest) // todo: move to DecodeOrBadRequest helper
if !helpers.DecodeJsonOrBadRequest(r.Body, w, &req, rt.baseLogger) {
return
}
err = rt.db.UpdateUsername(uid, req.Name)
//err := json.NewDecoder(r.Body).Decode(&req) //todo: capire se serve close
//if err != nil {
// w.WriteHeader(http.StatusBadRequest) // todo: move to DecodeOrBadRequest helper
// return
//}
err := rt.db.UpdateUsername(uid, req.Name)
if err != nil {
w.WriteHeader(http.StatusInternalServerError) // todo: is not ok, maybe let's use a helper