lens @ d6cf67b3d7747b6274d92e394d75d348060fa5f5

 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}