Implemented a thread-safe solution to the race condition that was causing random route overlaps

This commit is contained in:
Zeni Kim 2025-09-18 00:11:08 -05:00
parent 850d2ae477
commit e8f7ab40b5
2 changed files with 74 additions and 17 deletions

View file

@ -54,7 +54,11 @@ func (c *Context) Next() {
}
func (c *Context) prepare(ctx *Context) {
ctx.Request.httpRequest.ParseMultipartForm(int64(app.Config.Request.MaxUploadFileSize))
// Only parse multipart form if it hasn't been parsed already
// This prevents race conditions when multiple goroutines might access the same request
if ctx.Request.httpRequest.MultipartForm == nil {
ctx.Request.httpRequest.ParseMultipartForm(int64(app.Config.Request.MaxUploadFileSize))
}
}
func (c *Context) GetPathParam(key string) interface{} {