rc
is a response cache middleware for cache.
Prepare an instance that implements rc.Casher
interface.
Then, generate the middleware ( func(next http.Handler) http.Handler
) with rc.New
package main
import (
"log"
"net/http"
"github.com/2manymws/rc"
)
func main() {
r := http.NewServeMux()
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
})
var c rc.Cacher = newMyCacher()
m := rc.New(c)
log.Fatal(http.ListenAndServe(":8080", m(r)))
}