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)
|
response.WriteHeader(http.StatusAccepted)
|
||||||
_, err = response.Write([]byte("created"))
|
response.Write([]byte("created"))
|
||||||
if err != nil {
|
|
||||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func HttpHandleNewToken(response http.ResponseWriter, request *http.Request) {
|
func HttpHandleNewToken(response http.ResponseWriter, request *http.Request) {
|
||||||
@@ -136,12 +132,7 @@ func HttpHandleNewToken(response http.ResponseWriter, request *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
response.WriteHeader(http.StatusAccepted)
|
response.WriteHeader(http.StatusAccepted)
|
||||||
_, err = response.Write([]byte(token))
|
response.Write([]byte(token))
|
||||||
if err != nil {
|
|
||||||
CacheDeleteClient(client.Id)
|
|
||||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func HttpHandeNewGroup(response http.ResponseWriter, request *http.Request) {
|
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)
|
binary.BigEndian.PutUint32(groupIdBytes, group.Id)
|
||||||
|
|
||||||
response.WriteHeader(http.StatusCreated)
|
response.WriteHeader(http.StatusCreated)
|
||||||
_, err = response.Write(groupIdBytes)
|
response.Write(groupIdBytes)
|
||||||
if err != nil {
|
|
||||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func HttpHandleGroupAddClient(response http.ResponseWriter, request *http.Request) {
|
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)
|
http.Error(response, "invalid token", http.StatusUnauthorized)
|
||||||
}
|
}
|
||||||
ctx := request.Context()
|
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