Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
![coverage](https://raw.githubusercontent.com/cyberbeast/httpcache/badges/.badges/main/coverage.svg)

An HTTP transport for Go standard library's HTTP Client that caches HTTP Responses in a database to speed up subsequent requests. Currently supported:

1. `sqlite`
2. `postgres` (coming soon)

Expand All @@ -26,7 +27,7 @@ The implementation currently uses a very basic hashing mechanism to create a sig
## Todo

- [x] Basic Cache Invalidation support
- [ ] Add `postgres` as an alternative source
- [x] Add `postgres` as an alternative source
- [ ] Improve test coverage
- [ ] Add `pgxpool` support for `postgres` source
- [ ] Custom caching strategy based on HTTP response status codes
Expand Down
2 changes: 1 addition & 1 deletion hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func hash(headers http.Header) string {

var sb strings.Builder
for _, key := range keys {
sb.WriteString(fmt.Sprintf("%s:%s%s", key, headers.Get(key), delimiter))
fmt.Fprintf(&sb, "%s:%s%s", key, headers.Get(key), delimiter)
}

return sha256str([]byte(sb.String()))
Expand Down