Browse Source

Remove redunant w.WriteHeader lines after http.Error

pull/1/head
Tovi Jaeschke-Rogers 2 years ago
parent
commit
ecac186187
5 changed files with 0 additions and 16 deletions
  1. +0
    -1
      Backend/Api/Auth/Login.go
  2. +0
    -1
      Backend/Api/Auth/Signup.go
  3. +0
    -5
      Backend/Api/Friends/AcceptFriendRequest.go
  4. +0
    -7
      Backend/Api/Friends/Friends.go
  5. +0
    -2
      Backend/Api/Friends/RejectFriendRequest.go

+ 0
- 1
Backend/Api/Auth/Login.go View File

@ -43,7 +43,6 @@ func makeLoginResponse(w http.ResponseWriter, code int, message, pubKey, privKey
}, "", " ")
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}


+ 0
- 1
Backend/Api/Auth/Signup.go View File

@ -32,7 +32,6 @@ func makeSignupResponse(w http.ResponseWriter, code int, message string) {
}, "", " ")
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}


+ 0
- 5
Backend/Api/Friends/AcceptFriendRequest.go View File

@ -33,7 +33,6 @@ func AcceptFriendRequest(w http.ResponseWriter, r *http.Request) {
oldFriendRequest, err = Database.GetFriendRequestByID(friendRequestID)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -43,21 +42,18 @@ func AcceptFriendRequest(w http.ResponseWriter, r *http.Request) {
requestBody, err = ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
err = json.Unmarshal(requestBody, &newFriendRequest)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
err = Database.UpdateFriendRequest(&oldFriendRequest)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -67,7 +63,6 @@ func AcceptFriendRequest(w http.ResponseWriter, r *http.Request) {
err = Database.CreateFriendRequest(&newFriendRequest)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}


+ 0
- 7
Backend/Api/Friends/Friends.go View File

@ -22,14 +22,12 @@ func CreateFriendRequest(w http.ResponseWriter, r *http.Request) {
requestBody, err = ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
err = json.Unmarshal(requestBody, &friendRequest)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -38,14 +36,12 @@ func CreateFriendRequest(w http.ResponseWriter, r *http.Request) {
err = Database.CreateFriendRequest(&friendRequest)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
returnJSON, err = json.MarshalIndent(friendRequest, "", " ")
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -66,14 +62,12 @@ func CreateFriendRequestQrCode(w http.ResponseWriter, r *http.Request) {
requestBody, err = ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
err = json.Unmarshal(requestBody, &friendRequests)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
@ -85,7 +79,6 @@ func CreateFriendRequestQrCode(w http.ResponseWriter, r *http.Request) {
err = Database.CreateFriendRequests(&friendRequests)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}


+ 0
- 2
Backend/Api/Friends/RejectFriendRequest.go View File

@ -29,14 +29,12 @@ func RejectFriendRequest(w http.ResponseWriter, r *http.Request) {
friendRequest, err = Database.GetFriendRequestByID(friendRequestID)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}
err = Database.DeleteFriendRequest(&friendRequest)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
w.WriteHeader(http.StatusInternalServerError)
return
}


Loading…
Cancel
Save