A Go HTTP client library for creating and sending API requests with struct-based encoding and request composition.
Sling is a Go HTTP client library designed to simplify the creation and sending of API requests. It stores HTTP request properties to streamline building API clients and decoding responses, making it easier to interact with RESTful services.
Go developers building API clients for RESTful services, particularly those who want to avoid boilerplate code for request construction and response handling.
Developers choose Sling because it abstracts common patterns from API client libraries into a reusable component, promoting code reuse and simplifying client implementation across different services with features like struct encoding and automatic JSON decoding.
A Go HTTP client library for creating and sending API requests
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Encodes Go structs into URL query parameters or JSON/form bodies using tags, reducing boilerplate code for API parameters and payloads, as shown in the QueryStruct and BodyJSON examples.
Decodes JSON responses into structs for both success and failure cases via ReceiveSuccess and Receive methods, simplifying error handling and data parsing.
Method setters (Get, Post, etc.) and base/path composition allow readable, chainable request building with minimal repetition, as demonstrated in the usage examples.
The New() method creates independent child Slings, preventing accidental mutation and enabling safe reuse of base configurations for different endpoints.
Primarily supports JSON and form encoding; handling other formats like XML or multipart requires manual work with io.Reader and headers, adding complexity.
Lacks built-in retry logic, timeouts, or middleware, relying entirely on the standard http.Client for such functionality, which may require extra integration effort.
Relies on third-party libraries like go-querystring for struct tags, introducing an extra dependency and potential compatibility issues.