MCPcopy Create free account
hub / github.com/devfeel/dotweb / PostBody

Method PostBody

request.go:151–175  ·  view source on GitHub ↗

PostBody returns data from the POST or PUT request body

()

Source from the content-addressed store, hash-verified

149
150// PostBody returns data from the POST or PUT request body
151func (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
178func (req *Request) RemoteIP() string {

Callers 6

BindMethod · 0.80
BindJsonBodyMethod · 0.80
createUserFunction · 0.80
updateUserFunction · 0.80
BindMethod · 0.80
BindJsonBodyMethod · 0.80

Calls 4

httpAppMethod · 0.95
WriterMethod · 0.80
HttpServerMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected