Closed lsileoni closed 8 months ago
After some deliberation, a decision was to stick with a hybrid of configurability and templatability.
The templated solution covers the case where a user hasn't defined explicit error pages, but the server provides a convenient basic template for them.
If the user wants to customize error pages, they can do so through specifying the error page files in the config. These custom defined error pages also go through the templating engine.
Changes in: 5ed416c44823ca05b266f2d646f7525ca3d84e44
The current error response scheme was a bit janky. Ain't no one writing tens of different html files by hand. Thus, a I've made a very rudimentary templating engine which should be easy to extend for any more complex functionality.
Right now it's just taking a
template.html
file, performing a regexp search & substitution on it to replace a string with an error status code. More complex behaviour can be implemented but this should be enough for the subject's requirements on error statuses.TemplateEngine is fairly simple, it's a regex, which matches template strings like so:
And replaces them with their contemporary runtime values.
In the server side, we can define various valid placeholder variables and then add them to the replace mappings of the engine. Right now it's called like so:
Tests have been implemented in the
TemplateEngine.*pp
class files. They should show how it's expected to behave as of now.Other minor changes in this pr:
INFO
msgs for ConfigThis pull request closes #18