valyala / fasthttp

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
MIT License
21.94k stars 1.76k forks source link

Add support to fs.fs on serve static files #1640

Closed peczenyj closed 1 year ago

peczenyj commented 1 year ago

this is the following patch

https://patch-diff.githubusercontent.com/raw/valyala/fasthttp/pull/1374.patch

from pr #1374

however with smaller differences, lets continue this development?

should fix #974

erikdubbelboer commented 1 year ago

Thanks! And also thanks to @Aoang!

efectn commented 12 months ago

Hi @peczenyj. What about using root as path prefix when fs.FS is used. For example i have a directory like and i read it with os.DirFS("./views"):

views
├── index.slim
├── layouts
│   └── main.slim
└── partials
    ├── footer.slim
    ├── header.slim
    └── meta.slim

By default, Fasthttp will accept views/ as root and we will be able to access all files. If i want to specify partials/ as root what should i do without changing os.DirFs parameters? Root property of FS struct doesn't seem to work for a case like that.