lens @ ead855b7991b14554eb098616cfac29d91e796eb

 1package ext
 2
 3import (
 4	"io/fs"
 5
 6	"github.com/valyala/fasthttp"
 7)
 8
 9type FileSystem interface {
10	Open(name string) (fs.File, error)
11}
12
13func FileServer(rootFS FileSystem, rootPath string) fasthttp.RequestHandler {
14	return func(r *fasthttp.RequestCtx) {
15		path := r.UserValue("filepath").(string)
16		r.SendFile(rootPath + path)
17	}
18}