From 3d4b3651f2227b24630cb7e97cf50f27f641d50a Mon Sep 17 00:00:00 2001 From: Erika Harker Date: Fri, 20 Mar 2026 18:21:49 -0500 Subject: [PATCH] PDF --- context.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/context.go b/context.go index 9015159..157ad4e 100644 --- a/context.go +++ b/context.go @@ -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