Crow
Crow copied to clipboard
A method to set a new CROW_STATIC_DIRECTORY at runtime
Hello,
I would like to suggest an enhancement about CROW_STATIC_DIRECTORY because this definition is not always very convenient for building.
CROW_STATIC_DIRECTORY should be the default value for example and I would like to have a method to set a new value at runtime.
As done for crow::mustache::set_global_base for example. If the idea is appreciated I can create a pull request.
Joel
Hi, While I do agree migrating Crow away from macros is a good idea (especially when it comes to being able to run more than one app per process), I'm not sure allowing runtime changes of the static directory is a good idea. In fact it was never the intention for mustache::set_global_base to be used during runtime, only mustache::set_base.
I'm defining "runtime" here as being called after the execution of crow::run().
Hello @The-EDev Agree with you after run() is called allowing changing the directory is probably not a good idea. Removing this kind of macros can benefit people who want to build a library (I mean a .so file for example), which is much more convenient usually (Im' working on embedded system with Yocto and integrating crow in the build to populate the sdk should be a fantastic idea :-) ). Joel
Looking into this issue, CROW_STATIC_DIRECTORY was easily convertible to a function. the main problem was in the fact that CROW_STATIC_ENDPOINT is of type black_magic::const_str Which absolutely does not support runtime configuration. I'm not sure what trick I can employ to allow this, but if we are to take the language at face value, CROW_STATIC_ENDPOINT must stay a macro. Unless some C++11 version of a macro is possible.
Since this issue only references CROW_STATIC_DIRECTORY, the fix should be easy.. Do you think CROW_STATIC_ENDPOINT should also be part of this issue @joelguittet?
Agree, probably a common strategy and solution should be applied to several parameters.