imroc / req
Simple Go HTTP client with Black Magic
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing imroc/req in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewreq Simple Go HTTP client with Black Magic Documentation Full documentation is available on the official website: https://req.cool. Features • **Simple and Powerful**: Simple and easy to use, providing rich client-level and request-level settings, all of which are intuitive and chainable methods. • **Easy Debugging**: Powerful and convenient debug utilities, including debug logs, performance traces, and even dump the complete request and response content (see Debugging). • **Easy API Testing**: API testing can be done with minimal code, no need to explicitly create any Request or Client, or even to handle errors (See Quick HTTP Test) • **Smart by Default**: Detect and decode to utf-8 automatically if possible to avoid garbled characters (See Auto Decode), marshal request body and unmarshal response body automatically according to the Content-Type. • **Support Multiple HTTP Versions**: Support , , and , and can automatically detect the server side and select the optimal HTTP version for requests, you can also force the protocol if you want (See Force HTTP version). • **Support Retry**: Support automatic request retry and is fully customizable (See Retry). • **HTTP Fingerprinting**: Support http fingerprint impersonation, so that we can access websites that prohibit crawler programs by identifying http fingerprints (See HTTP Fingerprint). • **Multiple Authentication Methods**: You can use HTTP Basic Auth, Bearer Auth Token and Digest Auth out of box (see Authentication). • **Easy Download and Upload**: You can download and upload files with simple request settings, and even set a callback to show real-time progress (See Download and Upload). • **Exportable**: is exportable. Compared with , it also supports HTTP3, dump content, middleware, etc. It can directly replace the Transport of in existing projects, and obtain more powerful functions with minimal code change. • **Extensible**: Support Middleware for Request, Response, Client and Transport (See Request and Response Middleware) and Client and Transport Middleware). Get Started **Install** You first need Go installed (version 1.24+ is required), then you can use the below Go command to install req: **Import** Import req to your code: **Basic Usage** The sample code above is good for quick testing purposes, which use to see request details, and send requests using global wrapper methods that use the default client behind the scenes to initiate the request. In production, it is recommended to explicitly create a client, and then use the same client to send all requests, please see other examples below. **Videos** The following is a series of video tutorials for req: • Youtube Play List • BiliBili 播放列表 (Chinese) **More** Check more introduction, tutorials, examples, best practices and API references on the official website. Simple GET Advanced GET Normally it will output (SuccessState): More Advanced GET You can set up a unified logic for error handling on the client, so that each time you send a request you only need to focus on the success situation, reducing duplicate code. Simple POST Do API Style If you like, you can also use a Do API style like the following to make requests: • The order of chain calls is more intuitive: first call Client to create a request with a specified Method, then use chain calls to set the request, then use to fire the request, return Response, and finally call to unmarshal response body into specified object. • will return an error if an error occurs during sending the request or during unmarshalling. • The url of some APIs is fixed, and different types of requests are implemented by passing different bodies. In this scenario, can be used to set a unified url, and there is no need to set the url for each request when initiating a request. Of course, you can also call to set it if you need it. Build SDK With Req Here is an example of building GitHub's SDK with req, using two styles ( , ). Go Version Compatibility Matrix | Req Version | Go Version | | ----------- | ---------- | | 3.53.0 | 1.24+ | | 3.51.0 | 1.23+ | | 3.43.0 | 1.21+ | | 3.41.0 | 1.20+ | Contributing If you have a bug report or feature request, you can open an issue, and pull requests are also welcome. Contact If you have questions, feel free to reach out to us in the following ways: • Github Discussion • Slack | Join Sponsors If you like req and it really helps you, feel free to reward me with a cup of coffee, and don't forget to mention your github id. Wechat Alipay Many thanks to the following sponsors: M-Cosmosss 🥇 aadog 🥈 License released under MIT license, refer LICENSE file.