diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2023-01-06 01:22:38 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2023-01-06 01:27:48 -0500 |
| commit | 97dd660925434be537cd9a49a1d0c893b223e357 (patch) | |
| tree | 21d521b08f3a08eb2398a47893eb1543000387b8 /rediscache | |
| parent | 1d01acca36b78eeba99da1adb10e72d186433b39 (diff) | |
| download | go-website-97dd660925434be537cd9a49a1d0c893b223e357.tar.gz go-website-97dd660925434be537cd9a49a1d0c893b223e357.tar.xz | |
Refactor routing and handlers
We were building a new gorilla mux on each connection, change
that to an *http.ServeMux and build it once for the lifetime of
the application.
Tell redis to only cache GET requests.
Diffstat (limited to 'rediscache')
| -rw-r--r-- | rediscache/main.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/rediscache/main.go b/rediscache/main.go index 3cbfdea..b504a24 100644 --- a/rediscache/main.go +++ b/rediscache/main.go @@ -97,6 +97,12 @@ func Handle(pool *redis.Pool, key string, next http.Handler) http.Handler { func handle(pool *redis.Pool, key string, params bool, next http.Handler) http.Handler { //nolint:funlen return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + next.ServeHTTP(w, r) + + return + } + client := pool.Get() defer client.Close() |
