Commit a750622f authored by Mathieu Stefani's avatar Mathieu Stefani

Header::Collection: added an inplace construct function

parent efc830c1
......@@ -15,8 +15,8 @@ class MyHandler : public Net::Http::Handler {
using namespace Net::Http;
response.headers()
.add(std::make_shared<Header::Server>("lys"))
.add(std::make_shared<Header::ContentType>(MIME(Text, Plain)));
.add<Header::Server>("lys")
.add<Header::ContentType>(MIME(Text, Plain));
auto w = response.beginWrite(Net::Http::Code::Ok);
......
......@@ -53,6 +53,14 @@ public:
Collection& add(const std::shared_ptr<Header>& header);
Collection& addRaw(const Raw& raw);
template<typename H, typename ...Args>
typename std::enable_if<
IsHeader<H>::value, Collection&
>::type
add(Args&& ...args) {
return add(std::make_shared<H>(std::forward<Args>(args)...));
}
std::shared_ptr<const Header> get(const std::string& name) const;
std::shared_ptr<Header> get(const std::string& name);
Raw getRaw(const std::string& name) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment