2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20#include "express/Route.h"
22#include "express/Controller.h"
23#include "express/dispatcher/ApplicationDispatcher.h"
24#include "express/dispatcher/MiddlewareDispatcher.h"
25#include "express/dispatcher/RouterDispatcher.h"
27#ifndef DOXYGEN_SHOULD_SKIP_THIS
33#define DEFINE_ROUTE_REQUESTMETHOD(METHOD, HTTP_METHOD)
34 Route& Route::METHOD(const std::function<void(const std::shared_ptr<Request>&, const std::shared_ptr<Response>&, Next&)>& lambda)
36 return *(dispatcher->nextRoute = std::make_shared<Route>(
37 HTTP_METHOD, mountPoint.relativeMountPath, std::make_shared<dispatcher::MiddlewareDispatcher>(lambda)))
40 Route& Route::METHOD(const std::function<void(const std::shared_ptr<Request>&, const std::shared_ptr<Response>&)>& lambda) const {
41 return *(dispatcher->nextRoute = std::make_shared<Route>(
42 HTTP_METHOD, mountPoint.relativeMountPath, std::make_shared<dispatcher::ApplicationDispatcher>(lambda)))
53 Route::
Route(
const std::string& method,
const std::string& relativeMountPath,
const std::shared_ptr<
Dispatcher>& dispatcher)
59 return dispatch(controller,
"");
63 controller.setCurrentRoute(
this);
65 bool dispatched = dispatcher->dispatch(controller, parentMountPath, mountPoint);
68 dispatched = controller.dispatchNext(parentMountPath);
75 return dispatcher->dispatchNext(controller, parentMountPath);
#define DEFINE_ROUTE_REQUESTMETHOD(METHOD, HTTP_METHOD)
bool dispatch(Controller &controller, const std::string &parentMountPath)
Route(const std::string &method, const std::string &relativeMountPath, const std::shared_ptr< Dispatcher > &dispatcher)
bool dispatch(Controller &controller)
bool dispatchNext(Controller &controller, const std::string &parentMountPath)