You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Yann Esposito (Yogsototh) 5157c09bd7 Merge branch 'master' of github.com:yogsototh/wai-middleware-caching 6 years ago
..
src/Network/Wai/Middleware fix bug that cached bad responses 6 years ago
test initial commit 6 years ago
.gitignore initial commit 6 years ago
LICENSE initial commit 6 years ago
README.md added hackage badges 6 years ago
Setup.hs initial commit 6 years ago
stack.yaml initial commit 6 years ago
wai-middleware-caching.cabal fix bug that cached bad responses 6 years ago

README.md

WAI Middleware Caching

Hackage

This is a base to create caching WAI Middlewares

If you want to provide your own middleware you should provide a CacheBackend:


--------------------------------------------------------------------------------
-- | The data structure that should contains everything you need to create
-- a cache backend
data CacheBackend cacheContainer cacheKey cacheVal =
  CacheBackend {
  keyFromReq           :: Request -> ByteString -> IO cacheKey -- ^ Get cacheKey from request and its body
  , toCache            :: Request -> ByteString -> IO Bool -- ^ Function to check whether cache or not
  , addToCache         :: cacheContainer -> cacheKey -> cacheVal -> IO () -- ^ Adding to cache
  , actionOnCache      :: Request -> Response -> IO () -- ^ Action to perform before each caching request
  , actionOnCacheMiss  :: Request -> Response -> IO () -- ^ Action to perfom before each cache miss
  , responseToCacheVal :: Response -> IO cacheVal -- ^ Transform response to cached value
  , cacheValToResponse :: cacheVal -> Response -- ^ Transform cached value to response
  , lookupCache        :: cacheContainer -> cacheKey -> IO (Maybe cacheVal) -- ^ cache lookup
  , cacheContainer     :: cacheContainer -- ^ A cache container
  }