continue minIo, rename convertion methods and http methods
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"go-socket/packages/convertions"
|
||||
)
|
||||
|
||||
func HandleFileUpload(response http.ResponseWriter, request *http.Request) {
|
||||
if !postValidCheckWithResponseOnFail(&response, request, true) {
|
||||
return
|
||||
}
|
||||
ctx := request.Context()
|
||||
|
||||
user, err := getUserByToken(ctx, request.Header.Get("token"))
|
||||
if err != nil {
|
||||
http.Error(response, "invalid token", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
connectionId, err := convertions.ConvertStringUuid(request.FormValue("connectionid"))
|
||||
if err != nil {
|
||||
http.Error(response, "invalid connectionid", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
_, ok := user.Connections[connectionId]
|
||||
if !ok {
|
||||
http.Error(response, "no such connection", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user