How sari3l/requests works
Project Type and Purpose
• This is a Go‑library (“requests”) that simplifies HTTP calls (GET, POST, etc.), similar to Python’s requests.
• It provides a high‑level API (api.go, adapters.go) for building requests, sending them, parsing responses, and adding extensions (auth, data, hooks).
File Structure
Top‑level modules:
• api.go, adapters.go → Public API entry points
• request.go, response.go → Core request/response abstractions
• prepareRequest.go → Prepares net/http.Request from options
• sessions.go → Manages persistent configuration (cookies, headers)
• utils.go → Shared helper functions
• go.mod, go.sum → Module definitions
Subdirectories:
• ext/ → Extension hooks (Auth, Data, custom hook registration)
• internal/decoder → Response decoding (JSON, XML)
• internal/parser → XPath parsing
• internal/processbar → Progress bar for downloads
• internal/tracer → HTTP tracing support
• tools/ → Stand‑alone utilities (chromedp, downloader, hash, random, report)
• types/ → Data types (Auth, basic, bearer, extension args)
• template/ → Report generation templates
• docs/ → Markdown and static site files for documentation
README for Additional Insights
• Usage example shows core flow: types.BasicAuth → requests.Post → ext.Auth → ext.Data → resp.Json()
• Emphasizes extensibility via ext package and types for auth/data
Elements
• Clear Labels: name each module/file group, e.g., “Response Handler (response.go)”
– Blue rectangles for core library modules
– Green for extension/plugin layer
– Orange for internal utilities