func CDN(mountPoint string) func(cdnUrl string) string {
	if mountPoint != "" {
		if mountPoint[0] != '/' || mountPoint[len(mountPoint)-1] != '/' {
			panic(`mountpoint must start and end with "/"`)
		}
		http.Handle(mountPoint, http.StripPrefix(mountPoint, http.FileServer(http.Dir(CACHE_DIR))))
	}
	c := &cdn{
		cached:     map[string]struct{}{},
		mountPoint: mountPoint,
	}
	return c.path
}
CDN returns a function that may be used to return either the cdnUrl
or a local relative url, depending on mountPoint.

If mountPoint is empty, nothing is cached and the cdnUrl is returned.

Otherwise a fileserver is mounted at mountPoint, serving the files
from cache directory located at CDN_CACHE_DIR or - if not set - at tmp/cdn_cache.
Any call to the returned function will then ensure that the corresponding file
was downloaded to the cache directory and thus can be served by the fileserver.

mountPoint must either be empty or begin and end with /

An invalid mountPoint or an invalid cdnUrl results in a panic.
package cdncache
import (
	"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
	"path"
	"path/filepath"
)
type cdn struct {
	mountPoint string
	cached     map[string]struct{}
}
var CACHE_DIR = os.Getenv("CDN_CACHE_DIR")
func setCacheDir() {
	if CACHE_DIR == "" {
		CACHE_DIR = filepath.Join("tmp", "cdn_cache")
	}
}
func init() {
	setCacheDir()
}