Commit c1d91a1a authored by vicotor's avatar vicotor

add code

parent 439f4f08
......@@ -81,6 +81,25 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
}
defer r.Body.Close()
var reqs []RPCRequest
// 先尝试解析为批量请求
if err := json.Unmarshal(body, &reqs); err == nil {
// 处理批量请求
if len(reqs) > 1 {
req := reqs[0]
resp := RPCResponse{
Jsonrpc: req.Jsonrpc,
Id: req.Id,
Result: "0x0",
}
xForwardedFor := r.Header.Get("X-Forwarded-For")
log.Printf("stop forward to rpc on batch request, request from X-Forwarded-For: %s, param[0]: %v", xForwardedFor, req.Params)
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp)
}
return
}
var req RPCRequest
if err := json.Unmarshal(body, &req); err != nil {
forwardToBackend(w, body)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment