Skip to content

Commit

Permalink
Remove unsed, add fork info, run gomod init etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed May 17, 2024
1 parent 901d907 commit 10eb476
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 497 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
push:
branches: [master]
pull_request:
name: Test
permissions:
contents: read
jobs:
test:
strategy:
matrix:
go-version: [1.21.x, 1.22.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: ${{ matrix.go-version }}
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
shell: bash
- name: Update PATH
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Fmt
if: matrix.platform != 'windows-latest'
run: "diff <(gofmt -d .) <(printf '')"
shell: bash
- name: Vet
run: go vet ./...
- name: Staticcheck
# Ubuntu latest go.
if: strategy.job-index == 3
run: staticcheck ./...
- name: Test
run: go test -race ./... -coverpkg=./...
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright © 2012 Greg Jones (greg.jones@gmail.com)
Original work Copyright © 2012 Greg Jones (greg.jones@gmail.com)
Modified work Copyright © 2024 The Hugo Authors.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
27 changes: 4 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
httpcache
=========
[![Tests on Linux, MacOS and Windows](https://github.com/gohugoio/httpcache/workflows/Test/badge.svg)](https://github.com/gohugoio/httpcache/actions?query=workflow:Test)
[![Go Report Card](https://goreportcard.com/badge/github.com/gohugoio/httpcache)](https://goreportcard.com/report/github.com/gohugoio/httpcache)
[![GoDoc](https://godoc.org/github.com/gohugoio/httpcache?status.svg)](https://godoc.org/github.com/gohugoio/httpcache)

[![Build Status](https://travis-ci.org/gregjones/httpcache.svg?branch=master)](https://travis-ci.org/gregjones/httpcache) [![GoDoc](https://godoc.org/github.com/gregjones/httpcache?status.svg)](https://godoc.org/github.com/gregjones/httpcache)

Package httpcache provides a http.RoundTripper implementation that works as a mostly [RFC 7234](https://tools.ietf.org/html/rfc7234) compliant cache for http responses.

It is only suitable for use as a 'private' cache (i.e. for a web-browser or an API-client and not for a shared proxy).

This project isn't actively maintained; it works for what I, and seemingly others, want to do with it, and I consider it "done". That said, if you find any issues, please open a Pull Request and I will try to review it. Any changes now that change the public API won't be considered.

Cache Backends
--------------

- The built-in 'memory' cache stores responses in an in-memory map.
- [`github.com/gregjones/httpcache/diskcache`](https://github.com/gregjones/httpcache/tree/master/diskcache) provides a filesystem-backed cache using the [diskv](https://github.com/peterbourgon/diskv) library.
- [`github.com/gregjones/httpcache/memcache`](https://github.com/gregjones/httpcache/tree/master/memcache) provides memcache implementations, for both App Engine and 'normal' memcache servers.
- [`sourcegraph.com/sourcegraph/s3cache`](https://sourcegraph.com/github.com/sourcegraph/s3cache) uses Amazon S3 for storage.
- [`github.com/gregjones/httpcache/leveldbcache`](https://github.com/gregjones/httpcache/tree/master/leveldbcache) provides a filesystem-backed cache using [leveldb](https://github.com/syndtr/goleveldb/leveldb).
- [`github.com/die-net/lrucache`](https://github.com/die-net/lrucache) provides an in-memory cache that will evict least-recently used entries.
- [`github.com/die-net/lrucache/twotier`](https://github.com/die-net/lrucache/tree/master/twotier) allows caches to be combined, for example to use lrucache above with a persistent disk-cache.
- [`github.com/birkelund/boltdbcache`](https://github.com/birkelund/boltdbcache) provides a BoltDB implementation (based on the [bbolt](https://github.com/coreos/bbolt) fork).

If you implement any other backend and wish it to be linked here, please send a PR editing this file.
This is a fork of [gregjones/httpcache](https://github.com/gregjones/httpcache).

License
-------
Expand Down
61 changes: 0 additions & 61 deletions diskcache/diskcache.go

This file was deleted.

19 changes: 0 additions & 19 deletions diskcache/diskcache_test.go

This file was deleted.

3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/gohugoio/httpcache

go 1.22.2
6 changes: 2 additions & 4 deletions httpcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
//
// It is only suitable for use as a 'private' cache (i.e. for a web-browser or an API-client
// and not for a shared proxy).
//
package httpcache

import (
"bufio"
"bytes"
"errors"
"io"
"io/ioutil"
"net/http"
"net/http/httputil"
"strings"
Expand Down Expand Up @@ -234,7 +232,7 @@ func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error
R: resp.Body,
OnEOF: func(r io.Reader) {
resp := *resp
resp.Body = ioutil.NopCloser(r)
resp.Body = io.NopCloser(r)
respBytes, err := httputil.DumpResponse(&resp, true)
if err == nil {
t.Cache.Set(cacheKey, respBytes)
Expand Down Expand Up @@ -287,7 +285,7 @@ var clock timer = &realClock{}
// transparent indicates the response should not be used to fulfil the request
//
// Because this is only a private cache, 'public' and 'private' in cache-control aren't
// signficant. Similarly, smax-age isn't used.
// significant. Similarly, smax-age isn't used.
func getFreshness(respHeaders, reqHeaders http.Header) (freshness int) {
respCacheControl := parseCacheControl(respHeaders)
reqCacheControl := parseCacheControl(reqHeaders)
Expand Down
Loading

0 comments on commit 10eb476

Please sign in to comment.