| 105 | } |
| 106 | |
| 107 | func 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 | |
| 119 | func (a *API) needConfig() func(f interface{}) http.Handler { |
| 120 | if a.config == nil { |