This repository contains some useful middlewares for Cliware library.
Run go get github.com/delicb/cliware-middlewares in terminal.
Cliware middlewares are set of tools that can be used to create useful HTTP clients. On there own they do not do much, but to see how they they can be used to put together cool HTTP client, take a loko at GWC (HTTP client built on top of Cliware and Cliware-middlewares).
Middlewares are separated per packages that can be useful on their own. This is done to avoid dependencies between middlewars and create cleaner naming schema. Currently following packages exist:
- auth - authentication via header support
- body - handling request body, support setting JSON, XML, string and from io.Reader
- cookies - handling request cookies (add, set, delete)
- errors - handling HTTP error status codes and converting them to GoLang errors
- headers - handling request headers (add, set, delete)
- query - handling request query parameters (add, set, delete)
- responsebody - managing respones body, get json, string or write raw content to own writer
- retry - request retry mechanism based on custom classifier and with custom backoff
- url - handling URL endpoint for request (base URL, path)
Any contribution is welcome. If you find this code useful, please let me know. If you find bugs - feel free to open an issue, or, even better, new pull request.
Idea and bunch of implementation details were taken from cool GoLang HTTP client Gentleman. Difference is that these middewares are based on Cliware, instead of Gentleman builtin plugin mechanism.
Some ideas for retry middlewares are from go-resiliency project.
Cliware-middlewares is released under MIT licence.