fix main change owner route, fix group create id return, add new client
This commit is contained in:
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
json2 "encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
"slices"
|
||||
@@ -87,7 +87,7 @@ func getIfOwnerClientAndGroup(ctx context.Context, response *http.ResponseWriter
|
||||
return client, group, nil
|
||||
}
|
||||
|
||||
func HttpHandleNewUser(response http.ResponseWriter, request *http.Request) {
|
||||
func HttpHandleNewClient(response http.ResponseWriter, request *http.Request) {
|
||||
if !isMethodAllowed(&response, request) {
|
||||
return
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func HttpHandleNewUser(response http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
response.WriteHeader(http.StatusCreated)
|
||||
response.Write([]byte("created"))
|
||||
}
|
||||
|
||||
@@ -234,11 +234,8 @@ func HttpHandeNewGroup(response http.ResponseWriter, request *http.Request) {
|
||||
http.Error(response, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
groupIdBytes := make([]byte, 4)
|
||||
binary.BigEndian.PutUint32(groupIdBytes, group.Id)
|
||||
|
||||
response.WriteHeader(http.StatusCreated)
|
||||
response.Write(groupIdBytes)
|
||||
fmt.Fprintf(response, "%d", group.Id)
|
||||
}
|
||||
|
||||
func HttpHandleGroupAddClient(response http.ResponseWriter, request *http.Request) {
|
||||
@@ -295,11 +292,7 @@ func HttpHandleGroupAddClient(response http.ResponseWriter, request *http.Reques
|
||||
}
|
||||
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
_, err = response.Write([]byte("ok"))
|
||||
if err != nil {
|
||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
response.Write([]byte("ok"))
|
||||
}
|
||||
|
||||
func HttpHandleGroupRemoveClient(response http.ResponseWriter, request *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user