Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/crow/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ namespace crow
}

/// Set a response body size (in bytes) beyond which Crow automatically streams responses (Default is 1MiB)

///
/// Any streamed response is unaffected by Crow's timer, and therefore won't timeout before a response is fully sent.
self_t& stream_threshold(size_t threshold)
Expand Down
18 changes: 18 additions & 0 deletions include/crow/mustache.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,13 @@ namespace crow
static std::string template_base_directory = "templates";
return template_base_directory;
}

/// A base directory not related to any blueprint
inline std::string& get_global_template_base_directory_ref()
{
static std::string template_base_directory = "templates";
return template_base_directory;
}
} // namespace detail

inline std::string default_loader(const std::string& filename)
Expand Down Expand Up @@ -668,6 +675,17 @@ namespace crow
}
}

inline void set_global_base(const std::string& path)
{
auto& base = detail::get_global_template_base_directory_ref();
base = path;
if (base.back() != '\\' &&
base.back() != '/')
{
base += '/';
}
}

inline void set_loader(std::function<std::string(std::string)> loader)
{
detail::get_loader_ref() = std::move(loader);
Expand Down
4 changes: 2 additions & 2 deletions include/crow/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ namespace crow
{
if (!custom_templates_base.empty())
mustache::set_base(custom_templates_base);
else if (mustache::detail::get_template_base_directory_ref() != "templates")
mustache::set_base("templates");
else if (mustache::detail::get_template_base_directory_ref() != mustache::detail::get_global_template_base_directory_ref())
mustache::set_base(mustache::detail::get_global_template_base_directory_ref());

detail::routing_handler_call_helper::call<
detail::routing_handler_call_helper::call_params<decltype(handler_)>,
Expand Down