MCPcopy Create free account
hub / github.com/chain/Core / maxBytes

Function maxBytes

core/api.go:107–117  ·  view source on GitHub ↗
(h http.Handler)

Source from the content-addressed store, hash-verified

105}
106
107func maxBytes(h http.Handler) http.Handler {
108 const maxReqSize = 1e7 // 10MB
109 return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
110 // A block can easily be bigger than maxReqSize, but everything
111 // else should be pretty small.
112 if req.URL.Path != crosscoreRPCPrefix+"signer/sign-block" {
113 req.Body = http.MaxBytesReader(w, req.Body, maxReqSize)
114 }
115 h.ServeHTTP(w, req)
116 })
117}
118
119func (a *API) needConfig() func(f interface{}) http.Handler {
120 if a.config == nil {

Callers 1

buildHandlerMethod · 0.85

Calls 1

ServeHTTPMethod · 0.45

Tested by

no test coverage detected