a cache for CDN files
package main
import (
"fmt"
"gopkg.in/go-on/cdncache.v1"
"net/http"
)
// mounts the cached files at /cdn-cache/
var cdn1 = cdncache.CDN("/cdn-cache/")
// does no caching (empty mountpoint)
var cdn2 = cdncache.CDN("")
func serve(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w,
`<html>
<body>
<a href="%s">local (cached)</a><br>
<a href="%s">remote (CDN)</a><br>
</body>
</html>`,
cdn1("//code.jquery.com/jquery-1.11.0.min.js"),
cdn2("//code.jquery.com/jquery-1.11.0.min.js"),
)
}
func main() {
http.Handle("/", http.HandlerFunc(serve))
http.ListenAndServe(":8383", nil)
}
Version | Tag | Published |
---|---|---|
v0.0.0-20141215123906-fc3aa2f9f549 | 10mos ago | |
v1.2.1 | 3yrs ago |