Skip to content

Commit 5afef1e

Browse files
committed
feat: Add NewClient convenience function to create HTTP client with caching transport
1 parent b56afd3 commit 5afef1e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

roundtripper.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ func newTransport(conn driver.Conn, options ...Option) http.RoundTripper {
196196
return rt
197197
}
198198

199+
// NewClient returns a new [http.Client], configured with a transport that
200+
// caches HTTP responses using the specified cache backend.
201+
func NewClient(dsn string, options ...Option) *http.Client {
202+
return &http.Client{Transport: NewTransport(dsn, options...)}
203+
}
204+
199205
var _ http.RoundTripper = (*transport)(nil)
200206

201207
func (r *transport) RoundTrip(req *http.Request) (*http.Response, error) {

0 commit comments

Comments
 (0)