-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Better handling of static resources #41
Comments
I am not comfortable with this. Not with the embeding of static resources in general but with embeding HTML templates in particular. I have few objections against it:
Neither of the objections is particularly strong, but the same can be said for the benefits of bundling. As far as I can tell they are:
I am sure we can leave the static pages in their own files and deal with all the runtime problems at the same time. For example, a template may be compiled only once - at startup. And this is the proper way for dealing with templates. Once started, the server will not need the template file any more. This way we eliminate the runtime problem and only the startup problem remains. I would guess that a message at startup saying something like "Warning: a static resource was missing. Could not open " would be more than enough. The server will still start but "crippled" a bit. What do you think about it? RFC :) |
Good points - I agree with both the pros and the cons. I guess it depends on how many static resources we will have eventually. If it's just the status page and a few other simple pages, I still prefer that we make them embeded. If we have a lot of assets, especially ones that are customizable, It will be easier for them to be separate. And just a note on "template compilation on startup": if we do it this way, changing a single line in the template will require application restart, which may still be annoying, even if there is no compilation. |
A configuration variable or a command line option can be used to force the server to recompile the templates every time. But I guess the same method can be used when static resources are embeded. |
First I am more against the change than for it - mostly because the benefit is not so big and the downside is that we will have to have another dependency. On the other hand:
The proposed solution has problem 2 - I have to restart the server to see a change. I propose the install instruction to point out that if you want to have static files you have to copy them in the working dir. |
Or we can make nedomi search for the static resources on some predefined places. This way the installer will know where to put the files and the working directory will have no part in the business. |
that is a good solution or we can have another configuration in the config that is where the static files are. |
👍 |
Absolutely true! |
Some static resources (like
handler/status/templates/status_page.html
) have to be embedded in the source code. Otherwise, they may not be available at runtime.We can embed them manually as strings or use some of the tools mentioned here or write a simple go generate tool of our own.
The text was updated successfully, but these errors were encountered: