| 144 | /// which is rendered via a template file, or it produces an HTML string that is embedded |
| 145 | /// directly into the output. |
| 146 | class UrlHandler { |
| 147 | public: |
| 148 | UrlHandler(const UrlCallback& cb, const std::string& template_filename, |
| 149 | bool is_on_nav_bar) |
| 150 | : is_on_nav_bar_(is_on_nav_bar), use_templates_(true), template_callback_(cb), |
| 151 | template_filename_(template_filename) { } |
| 152 | |
| 153 | UrlHandler(const RawUrlCallback& cb) |
| 154 | : is_on_nav_bar_(false), use_templates_(false), |
| 155 | raw_callback_(cb) { } |
| 156 | |
| 157 | bool is_on_nav_bar() const { return is_on_nav_bar_; } |
| 158 | bool use_templates() const { return use_templates_; } |
| 159 | const UrlCallback& callback() const { return template_callback_; } |
| 160 | const RawUrlCallback& raw_callback() const { return raw_callback_; } |
| 161 | const std::string& template_filename() const { return template_filename_; } |
| 162 | |
| 163 | private: |
| 164 | /// If true, the page appears in the navigation bar. |
| 165 | const bool is_on_nav_bar_; |
| 166 | |
| 167 | /// If true, use the template rendering callback, otherwise the 'raw' callback is |
| 168 | /// used. |
| 169 | const bool use_templates_; |
| 170 | |
| 171 | /// Callback to produce a Json document to render via a template. |
| 172 | UrlCallback template_callback_; |
| 173 | |
| 174 | /// Callback to produce a raw bytestream. |
| 175 | RawUrlCallback raw_callback_; |
| 176 | |
| 177 | /// Path to the file that contains the template to render, relative to the webserver's |
| 178 | /// document root. |
| 179 | std::string template_filename_; |
| 180 | }; |
| 181 | |
| 182 | /// Sets the values of 'url_' and 'hostname_'. |
| 183 | void Init(); |
no outgoing calls
no test coverage detected