Skip to content
/ rc Public

rc is a response cache middleware for cache.

License

Notifications You must be signed in to change notification settings

2manymws/rc

Repository files navigation

rc Go Reference build Coverage Code to Test Ratio Test Execution Time

rc is a response cache middleware for cache.

Usage

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)))
}

Utility functions

See https://github.com/2manymws/rcutil