Open Warxcell opened 3 months ago
Hey @Warxcell 👋 This is a great idea 👍 Would you be able to send a PR ?
Hey @Warxcell 👋 This is a great idea 👍 Would you be able to send a PR ?
I will try, but I don't have any experience with Go. :rofl:
Sure, you may use a map[string]*os.File
to have the list of scanned files. Should also check for nils, handle errors on accessing the file (log them, but not interrupt a request) and delete that file if the user deleted it from the disk, for example.
I'll help you on the review stage 😃
https://github.com/roadrunner-server/static/pull/126
this is my progress so far, I have difficulties: how to scan rootDir for files, recursively?
@Warxcell You may use filepath.Walk
@Warxcell You may use
filepath.Walk
Thanks! I think I'm ready, but no idea how to test it tho :D neither found tests for this middleware
Plugin
HTTP Middleware (any)
I have an idea!
it would be cool if static HTTP middleware have option
immutable
- so when turned on - it would scan all files in root dir on startup and cache their properties in memory, so with that option roadrunner won't needStatic HTTP middleware slows down request processing by ~10% because RR has to check each request for the corresponding file.
thus enabling static http middleware, will have zero performance impact. Furthermore it can be used to send https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control immutable option.Because some projects may run inside docker with read-only filesystem, so roadrunner can be 100% sure that files WON'T change after startup.