working file sharing

This commit is contained in:
2026-04-16 20:38:16 +02:00
parent f0fdaedd8c
commit 84e3f852fe
14 changed files with 190 additions and 81 deletions
+21
View File
@@ -0,0 +1,21 @@
package httpRequest
import (
"net/http"
"go-socket/packages/globals"
)
func postValidCheckWithResponseOnFail(response *http.ResponseWriter, request *http.Request, withFile bool) bool {
if request.Method != http.MethodPost {
http.Error(*response, "POST only", http.StatusMethodNotAllowed)
return false
}
if withFile && request.ContentLength > int64(globals.MaxPostWithFileBytes) ||
!withFile && request.ContentLength > int64(globals.MaxPostBytes) {
http.Error(*response, "Request too large", http.StatusRequestEntityTooLarge)
return false
}
return true
}