fix websocket messaging, renamed http functions, start sending message via http
This commit is contained in:
@@ -87,7 +87,7 @@ func HttpHandleNewUser(response http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func HttpHandleLogin(response http.ResponseWriter, request *http.Request) {
|
||||
func HttpHandleNewToken(response http.ResponseWriter, request *http.Request) {
|
||||
if !isMethodAllowed(&response, request) {
|
||||
return
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func HttpHandleLogin(response http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func HttpHandleGroupCreate(response http.ResponseWriter, request *http.Request) {
|
||||
func HttpHandeNewGroup(response http.ResponseWriter, request *http.Request) {
|
||||
if !isMethodAllowed(&response, request) {
|
||||
return
|
||||
}
|
||||
@@ -208,7 +208,11 @@ func HttpHandleGroupCreate(response http.ResponseWriter, request *http.Request)
|
||||
binary.BigEndian.PutUint32(groupIdBytes, group.Id)
|
||||
|
||||
response.WriteHeader(http.StatusCreated)
|
||||
response.Write(groupIdBytes)
|
||||
_, err = response.Write(groupIdBytes)
|
||||
if err != nil {
|
||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func HttpHandleGroupAddClient(response http.ResponseWriter, request *http.Request) {
|
||||
@@ -288,3 +292,27 @@ func HttpHandleGroupAddClient(response http.ResponseWriter, request *http.Reques
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func HttpHandleNewMessage(response http.ResponseWriter, request *http.Request) {
|
||||
token := request.FormValue("token")
|
||||
if token == "" {
|
||||
http.Error(response, "invalid token", http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
subject := request.FormValue("subject")
|
||||
if subject == "" {
|
||||
http.Error(response, "invalid subject", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
content := request.FormValue("content")
|
||||
if content == "" {
|
||||
http.Error(response, "invalid content", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
clientId, err := TokenValidateGetId(token)
|
||||
if err != nil {
|
||||
http.Error(response, "invalid token", http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user