Effective HTTP Interface Debugging with pproxy and api-front: Tools, Features, and Deployment
This article explains how to improve HTTP API debugging and testing by using two Golang‑based tools—pproxy, a cross‑platform proxy for capturing and modifying traffic, and api‑front, a BS‑architecture front‑end that forwards, records, and replicates API calls—detailing their features, usage, and deployment scenarios.
The author, a backend developer, shares practical methods for debugging HTTP interfaces, emphasizing the need to inspect both client requests and server responses. While tools like Fiddler work on a single machine, they become cumbersome in collaborative environments with changing IPs.
To address this, the author created pproxy , a Golang‑written, cross‑platform, browser‑server (BS) architecture HTTP proxy that can be deployed on Linux test servers. By setting a mobile device’s global proxy to pproxy’s listening port, developers can capture and analyze traffic without the limitations of desktop‑only tools.
Key features of pproxy include:
URL redirection (e.g., redirecting http://www.baidu.com/s?wd=pproxy to http://m.baidu.com/s?wd=pproxy or WebSocket endpoints).
Dynamic form modification for GET/POST parameters.
Hosts file support, allowing domain‑to‑IP mapping (e.g., www.baidu.com 127.0.0.1 or port‑specific mapping).
Detailed request and response inspection (headers, form data, etc.).
HTTP Basic authentication support.
Request replay with editable parameters.
Parent proxy chaining.
Dynamic request modification can be scripted in JavaScript, offering great flexibility. Example snippets:
if(req.host=="www.baidu.com"){
req.host="www.163.com";
req.host_addr="127.0.0.0:81"; // send req to 127.0.0.1:81
}or
if(req.host.indexOf("baidu.com")>-1){
req.host_addr="127.0.0.0:81";
}For backend services where setting a proxy for each request is impractical, the author introduces api‑front , another Golang BS‑architecture tool that acts as an API front‑end. It forwards incoming requests to real backend services, provides protocol analysis, traffic copying, and simplifies multi‑version API testing.
api‑front’s architecture is illustrated in the accompanying diagram, showing both simple forwarding to a single backend server and a traffic‑copy mode where one client request is dispatched to multiple downstream servers (useful for stateless stream processing or notification scenarios).
Deployment screenshots demonstrate a local run of pproxy and the UI of api‑front, highlighting how team members can share captured requests, replay them, and collaboratively debug issues.
Overall, the two tools significantly reduce API integration testing costs, improve debugging efficiency, and provide flexible mechanisms for request manipulation, host rewriting, and traffic replication in backend development workflows.
Baidu Intelligent Testing
Welcome to follow.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.