summaryrefslogtreecommitdiff
path: root/src/http/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/http.go')
-rw-r--r--src/http/http.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/http/http.go b/src/http/http.go
index 98cdde3..d51671d 100644
--- a/src/http/http.go
+++ b/src/http/http.go
@@ -15,7 +15,7 @@ import (
"strings"
"time"
- lru "github.com/hashicorp/golang-lru"
+ "github.com/mediocregopher/blog.mediocregopher.com/srv/cache"
"github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
"github.com/mediocregopher/blog.mediocregopher.com/srv/http/apiutil"
"github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist"
@@ -33,6 +33,7 @@ var staticFS embed.FS
type Params struct {
Logger *mlog.Logger
PowManager pow.Manager
+ Cache cache.Cache
PostStore post.Store
PostAssetStore post.AssetStore
@@ -190,13 +191,6 @@ func (a *api) apiHandler() http.Handler {
func (a *api) blogHandler() http.Handler {
- cache, err := lru.New(5000)
-
- // instantiating the lru cache can't realistically fail
- if err != nil {
- panic(err)
- }
-
mux := http.NewServeMux()
mux.Handle("/posts/", http.StripPrefix("/posts",
@@ -244,11 +238,11 @@ func (a *api) blogHandler() http.Handler {
readOnlyMiddlewares := []middleware{
logReqMiddleware, // only log GETs on cache miss
- cacheMiddleware(cache),
+ cacheMiddleware(a.params.Cache, a.params.PublicURL),
}
readWriteMiddlewares := []middleware{
- purgeCacheOnOKMiddleware(cache),
+ purgeCacheOnOKMiddleware(a.params.Cache),
authMiddleware(a.auther),
}