delete response error check, fix new message logic
This commit is contained in:
@@ -80,11 +80,7 @@ func HttpHandleNewUser(response http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
_, err = response.Write([]byte("created"))
|
||||
if err != nil {
|
||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
response.Write([]byte("created"))
|
||||
}
|
||||
|
||||
func HttpHandleNewToken(response http.ResponseWriter, request *http.Request) {
|
||||
@@ -136,12 +132,7 @@ func HttpHandleNewToken(response http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
_, err = response.Write([]byte(token))
|
||||
if err != nil {
|
||||
CacheDeleteClient(client.Id)
|
||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
response.Write([]byte(token))
|
||||
}
|
||||
|
||||
func HttpHandeNewGroup(response http.ResponseWriter, request *http.Request) {
|
||||
@@ -208,11 +199,7 @@ func HttpHandeNewGroup(response http.ResponseWriter, request *http.Request) {
|
||||
binary.BigEndian.PutUint32(groupIdBytes, group.Id)
|
||||
|
||||
response.WriteHeader(http.StatusCreated)
|
||||
_, err = response.Write(groupIdBytes)
|
||||
if err != nil {
|
||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
response.Write(groupIdBytes)
|
||||
}
|
||||
|
||||
func HttpHandleGroupAddClient(response http.ResponseWriter, request *http.Request) {
|
||||
@@ -318,5 +305,11 @@ func HttpHandleNewMessage(response http.ResponseWriter, request *http.Request) {
|
||||
http.Error(response, "invalid token", http.StatusUnauthorized)
|
||||
}
|
||||
ctx := request.Context()
|
||||
WsSendToGroup(ctx, targetId, clientId, content)
|
||||
err = WsSendToGroup(ctx, targetId, clientId, content)
|
||||
if err != nil {
|
||||
http.Error(response, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
response.Write([]byte("sent"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user