PostBody returns data from the POST or PUT request body
()
| 149 | |
| 150 | // PostBody returns data from the POST or PUT request body |
| 151 | func (req *Request) PostBody() []byte { |
| 152 | if !req.isReadBody { |
| 153 | if req.httpCtx != nil { |
| 154 | switch req.httpCtx.HttpServer().DotApp.Config.Server.MaxBodySize { |
| 155 | case -1: |
| 156 | break |
| 157 | case 0: |
| 158 | req.Body = http.MaxBytesReader(req.httpCtx.Response().Writer(), req.Body, maxBodySize) |
| 159 | break |
| 160 | default: |
| 161 | req.Body = http.MaxBytesReader(req.httpCtx.Response().Writer(), req.Body, req.httpApp().Config.Server.MaxBodySize) |
| 162 | break |
| 163 | } |
| 164 | } |
| 165 | bts, err := ioutil.ReadAll(req.Body) |
| 166 | if err != nil { |
| 167 | //if err, panic it |
| 168 | panic(err) |
| 169 | } else { |
| 170 | req.isReadBody = true |
| 171 | req.postBody = bts |
| 172 | } |
| 173 | } |
| 174 | return req.postBody |
| 175 | } |
| 176 | |
| 177 | // RemoteIP RemoteAddr to an "IP" address |
| 178 | func (req *Request) RemoteIP() string { |
no test coverage detected