passed/routes/serve_files.go

16 lines
228 B
Go
Raw Normal View History

2024-10-29 23:08:11 +00:00
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)
}