fasthttp icon indicating copy to clipboard operation
fasthttp copied to clipboard

Ability to serve embed.FS files

Open night-codes opened this issue 4 years ago • 4 comments

Will there be a native fasthttp way (like .ServeFile) to share filesystems of embedded files, support for which came in go 1.16?

https://golang.org/doc/go1.16#library-embed

night-codes avatar Feb 20 '21 23:02 night-codes

A pull request for that would be very welcome. Maybe add a FS fs.FS member to fasthttp.FS and if it's not nil use FS.open instead of os.Open.

erikdubbelboer avatar Feb 21 '21 13:02 erikdubbelboer

@erikdubbelboer with that solution, how might it handle mustCompress? Or just not support it for embedded content?

lukekim avatar Jul 19 '21 10:07 lukekim

Yeah I guess that's not supported then.

erikdubbelboer avatar Jul 20 '21 16:07 erikdubbelboer

I'm willing to try this feature, my basic thought is to add a interface like

StaticFSHandler(prePath string, staticFS fs.FS) RequestHandler

and modify fasthttp.FS as talked above

byene0923 avatar May 25 '22 18:05 byene0923