func DirHandler(dir string, strippedPrefix string) http.Handler {
	if dir == "" {
		return errorHandler(http.StatusNoContent)
	}
	dir = strings.Replace(dir, "/", PathSeparator, -1)
	h := http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
		reqpath := req.URL.Path
		if !strings.HasPrefix(reqpath, "/") {
			reqpath = PathSeparator + reqpath
			req.URL.Path = reqpath
		}
		reqpath = path.Clean(reqpath)
		fpath := reqpath
		relpath, err := filepath.Rel(dir, reqpath)
		if err != nil {
			abspath, err := filepath.Abs(dir + reqpath)
			if err == nil {
				fpath = abspath
			}
		} else {
			fpath = relpath
		}
		http.ServeFile(res, req, fpath)
	})
	return http.StripPrefix(strippedPrefix, h)
}
DirHandler serves a directory as web resource
accepts a system Directory (string),
a string which will be stripped off if not empty and
Note 1: this is a dynamic dir handler, means that if a new file is added to the folder it will be served
Note 2: it doesn't cache the system files, use it with your own risk, otherwise you can use the http.FileServer method, which is different of what I'm trying to do here.
example:
staticHandler := http.FileServer(http.Dir("static"))
http.Handle("/static/", http.StripPrefix("/static/", staticHandler))
converted to ->
http.Handle("/static/", fs.DirHandler("./static", "/static/"))
package fs
import (
	"io/ioutil"
	"net/http"
	"os"
	"path"
	"path/filepath"
	"strings"
	"time"
)
var (
	TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
	StaticCacheDuration = 20 * time.Second
	Charset = "utf-8"
)
var (
	contentTypeHeader = "Content-Type"
	contentLength = "Content-Length"
	contentEncodingHeader = "Content-Encoding"
	varyHeader = "Vary"
	acceptEncodingHeader = "Accept-Encoding"
	lastModified = "Last-Modified"
	ifModifiedSince = "If-Modified-Since"
	contentDisposition = "Content-Disposition"
	contentBinary = "application/octet-stream"
)
func setContentType(res http.ResponseWriter, contentTypeValue string, alternative string) {
	if contentTypeValue == "" && res.Header().Get("Content-Type") == "" {
		contentTypeValue = alternative
	}
	if !strings.Contains(contentTypeValue, ";charset=") && contentTypeValue != contentBinary {
		contentTypeValue += "; charset=" + Charset
	}
	res.Header().Set(contentTypeHeader, contentTypeValue)
}
func errorHandler(httpStatusCode int) http.Handler {
	return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
		line := http.StatusText(httpStatusCode)
		if line == "" {
			line = http.StatusText(http.StatusBadRequest)
		}
		http.Error(res, line, httpStatusCode)
	})
}
func StaticContentHandler(data []byte, contentType string) http.Handler {
	if len(data) == 0 {
		return errorHandler(http.StatusNoContent)
	}
	modtime := time.Now()
	modtimeStr := modtime.UTC().Format(TimeFormat)
	return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
		if t, err := time.Parse(TimeFormat, req.Header.Get(ifModifiedSince)); err == nil && modtime.Before(t.Add(StaticCacheDuration)) {
			res.Header().Del(contentTypeHeader)
			res.Header().Del(contentLength)
			res.WriteHeader(http.StatusNotModified)
			return
		}
		setContentType(res, contentType, contentBinary)
		res.Header().Set(lastModified, modtimeStr)
		res.Write(data)
	})
}
func StaticFileHandler(filename string) http.Handler {
	fcontents, err := ioutil.ReadFile(filename)  
	if err != nil {
		return errorHandler(http.StatusBadRequest)
	}
	return StaticContentHandler(fcontents, TypeByExtension(filename))
}
func SendStaticFileHandler(filename string) http.Handler {
	staticHandler := StaticFileHandler(filename)
	_, sendfilename := filepath.Split(filename)
	h := http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
		staticHandler.ServeHTTP(res, req)
		res.Header().Set(contentDisposition, "attachment;filename="+sendfilename)
	})
	return h
}
func FaviconHandler(favPath string) http.Handler {
	f, err := os.Open(favPath)
	if err != nil {
		panic(errFileOpen.Format(favPath, err.Error()))
	}
	defer f.Close()
	fi, _ := f.Stat()
	if fi.IsDir() {  
		fav := path.Join(favPath, "favicon.ico")
		f, err = os.Open(fav)
		if err != nil {
			favPath = path.Join(favPath, "favicon.png")
			return FaviconHandler(favPath)
		}
		favPath = fav
		fi, _ = f.Stat()
	}
	cType := TypeByExtension(favPath)
	cacheFav := make([]byte, fi.Size())
	if _, err = f.Read(cacheFav); err != nil {
		panic(errFileRead.Format(favPath, "Favicon: "+err.Error()))
	}
	return StaticContentHandler(cacheFav, cType)
}
const slash = "/"