passed/routes/serve_files.go
2024-10-30 00:08:11 +01:00

15 lines
228 B
Go

package routes
import (
"io/fs"
"net/http"
)
func ServeFiles(fileSystem fs.FS, pathInFs string) http.Handler {
newFs, err := fs.Sub(fileSystem, pathInFs)
if err != nil {
panic(err)
}
return http.FileServerFS(newFs)
}