-
Notifications
You must be signed in to change notification settings - Fork 34
embedded static and template files #18
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
base: master
Are you sure you want to change the base?
Conversation
|
This is really cool. I'm wondering if we can do one better by checking the filesystem first and then falling back to embedded? For example, it's currently possible to override the templates with whatever you want simply by replacing the file. In my case, I mostly want to edit With the proposed implementation, if I want to override any static file or template, I have to extract and serve everything in The Something like: type fallbackFS []fs.FS
func (ff fallbackFS) Open(name string) (fs.File, error) {
... iterate over the fs'es and try and Open() the file, if it fails move on to the next one. The last FS should be the embed.FS ...
}And then you'd initialise it like: staticFS = fallbackFS{os.DirFS(c.Dirs.Static), staticFiles}
...
http.FileServer(staticFS) |
|
Hey folks, apologies for the absence—moved halfway across the globe so still getting settled down. Still need a few days to sort stuff out and I’ll get to reviewing this. Thanks! |
|
@daenney that sort of behavior is ideal but the increase complexity makes me stay away from it. The config option suggested by @gedw99 ensures user has more control than the binary. Also we can have the binary output the template and the config. The user can then just make edits to the template to be overridden in config. We can then just distribute the binary with default config and templates instead of cloning and setting up everything. |
|
For now @icyphox I think we can merge this PR and raise a separate issue for above feature. |
|
Upon further testing and analysis I found that this PR is going to break upstream functionality if merged. @icyphox do we need absolute path update of I needed those variables to be empty to check if we should be using embedded templates. |
No description provided.