This commit is contained in:
Erika Harker 2026-03-20 18:21:49 -05:00
parent 9d83eed4f3
commit 3d4b3651f2

View file

@ -89,6 +89,22 @@ func (c *Context) GetRequesBodyMap() map[string]interface{} {
return dat
}
// get raw data for file binary
func (c *Context) GetRawBody() ([]byte, error) {
if c.Request.httpRequest.Body == nil {
return nil, errors.New("empty body")
}
defer c.Request.httpRequest.Body.Close()
data, err := io.ReadAll(c.Request.httpRequest.Body)
if err != nil {
return nil, err
}
return data, nil
}
// get json body and bind to dest interface
func (c *Context) GetRequesBodyStruct(dest interface{}) error {
body := c.Request.httpRequest.Body