aboutsummaryrefslogtreecommitdiffstats
path: root/include/crow.h
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2014-09-07 04:30:53 +0900
committeripknHama <ipknhama@gmail.com>2014-09-07 04:30:53 +0900
commit2748e35430b9a4aaf64dfbd626d819f0fc5eedd2 (patch)
treea8ebd5648d46cc7073b2ae6f6b5ada0e702c456c /include/crow.h
parentc89cafa820ec02f041c3b0e52877bc321f6a1ba9 (diff)
downloadcrow-2748e35430b9a4aaf64dfbd626d819f0fc5eedd2.tar.gz
crow-2748e35430b9a4aaf64dfbd626d819f0fc5eedd2.zip
basic middleware test: before_handler
Diffstat (limited to 'include/crow.h')
-rw-r--r--include/crow.h16
1 files changed, 6 insertions, 10 deletions
diff --git a/include/crow.h b/include/crow.h
index a018f31..a4b82df 100644
--- a/include/crow.h
+++ b/include/crow.h
@@ -13,12 +13,9 @@
#include "http_server.h"
#include "utility.h"
#include "routing.h"
-#include "middleware_impl.h"
+#include "middleware_context.h"
#include "http_request.h"
-// TEST
-#include <iostream>
-
#define CROW_ROUTE(app, url) app.route<crow::black_magic::get_parameter_tag(url)>(url)
namespace crow
@@ -28,13 +25,14 @@ namespace crow
{
public:
using self_t = Crow;
+ using server_t = Server<Crow, Middlewares...>;
Crow()
{
}
void handle(const request& req, response& res)
{
- return router_.handle(req, res);
+ router_.handle(req, res);
}
template <uint64_t Tag>
@@ -71,7 +69,7 @@ namespace crow
void run()
{
validate();
- Server<self_t> server(this, port_, concurrency_);
+ server_t server(this, port_, concurrency_);
server.run();
}
@@ -84,19 +82,17 @@ namespace crow
// middleware
using context_t = detail::context<Middlewares...>;
template <typename T>
- T& get_middleware_context(request& req)
+ typename T::context& get_middleware_context(const request& req)
{
static_assert(black_magic::contains<T, Middlewares...>::value, "App doesn't have the specified middleware type.");
auto& ctx = *reinterpret_cast<context_t*>(req.middleware_context);
- return ctx.get<T>();
+ return ctx.template get<T>();
}
private:
uint16_t port_ = 80;
uint16_t concurrency_ = 1;
- std::tuple<Middlewares...> middlewares_;
-
Router router_;
};
template <typename ... Middlewares>