-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add is_dir helper function to metadata #193
Conversation
Workflow is fixed: https://github.com/jaztec/rust-embed/actions/runs/3504800911 |
LGTM |
I've been writing some tests and noticed it is not possible to fetch a folder anyway. That does make this PR a tad useless. I could extend https://github.com/pyrossh/rust-embed/blob/master/utils/src/lib.rs#L111 a bit to also read a folder but I'm not sure what behavior should be displayed and/or what usecase it would fullfill. |
Yes I was wondering that. I thought it could be useful to do some recursive stuff. Or maybe get a default |
I updated the function, it will now read the directory metadata but keeps a clear |
Fetching an |
I would leave that upto the user to implement it in the web framework of their choice, as its a specific scenario that only applies to JAM stack based websites. |
Thanks @jaztec |
I fixed the BC break issue by the way, I scr*wed up big time there. jaztec@13fabb9 However the branch still doesn't add any real value. I would like to extend a next PR to actually include folders as new root elements. So you can use something like So it can be an actual BC breaking version bump. |
I guess instead of overriding the |
True, that would not cause a break.
I was thinking of a usecase I once build in Go, it was a project which used a rule engine to handle incoming requests based on hostname and path. It would either proxy a placeholder, redirect to a marketing site or dynamically load a SPA website if it was present. But thinking again I recon the entire purpose of the library is loading from embedded files, thus files known at compile time. When I got the assets at compile time there is no need anymore to load them dynamically I guess. You want me to make a safe PR for the |
This is still a breaking change unless the new trait function has a default implementation. It's possible for users to implement RustEmbed on their own types (ex. to mock it). |
True again, from a different participator this time. I actually don't think having dynamic folders is usefull anymore, just because my last comment as a whole. At compile time you are aware of the folders included and so you can embed them at your own discretion. Having it be loaded dynamically doesn't add any value. My only question now is; do I submit a new PR for this
Based on this: jaztec@13fabb9 |
I think we need to understand the use case behind #170 before doing any implementation. |
Let's open it up then. I can't so be my guest |
Jumping on #170, adding an
is_dir
helper function based on fs metadata.