Hi guys, any examples of using a custom Configurat...
# http4k
a
Hi guys, any examples of using a custom Configuration with a templating engine? I am using freemarker, however the default usage logs a severe error on every call (it's because http4k uses
Configuration(Configuration.getVersion())
instead of a specific version:
Configuration(Configuration.VERSION_2_3_30)
)... but I am striking out when trying to provide a custom Configuration. Also useful for providing custom string formats, equality checks, etc.
d
You should be able to pass a configuration lambda to the constructor but if you can't modify the version.... Just throw away the one that comes into the lambda and create your own! https://github.com/http4k/http4k/blob/master/http4k-template/freemarker/src/main/kotlin/org/http4k/template/FreemarkerTemplates.kt
a
Hi David, yes I tried this before messaging, however a new configuration lambda still gets overridden by hard-coded
Configuration.getVersion()
within
HotReload
and the other functions. I also tried to just override
HotReload
completely but it relies on
FreemarkerTemplateResolver
which is private and therefore non-accessible in a new class.
d
ah - yes - we have some brackets in the wrong place. I've updated it in master but can you please take a copy until then?
a
sure, this is not a breaking issue that needs an immediate fix. However I'm not sure how what you changed fixes the issue? How can I override the
Configuration.getVersion()
, this is the code that freemarker wants users to avoid: "_Never use a dynamic value like 
Configuration.getVersion()
 though, as that way upgrading FreeMarker can break your application!_" (https://freemarker.apache.org/docs/pgui_config_incompatible_improvements.html)
d
just create your freemarker like this:
Copy code
FreemarkerTemplates({
        Configuration(Configuration.getVersion())
    })
.. but replaceing the getVersion with whichever one you want
a
ok, that's exactly what I tried yesterday -- I will test with the fix you made upon the next release. thanks for the quick replies.