SNode.C
Loading...
Searching...
No Matches
express::dispatcher::ApplicationDispatcher Class Reference

#include <ApplicationDispatcher.h>

Inheritance diagram for express::dispatcher::ApplicationDispatcher:
Collaboration diagram for express::dispatcher::ApplicationDispatcher:

Public Member Functions

 ApplicationDispatcher (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda)
 
- Public Member Functions inherited from express::Dispatcher
 Dispatcher (const Dispatcher &)=delete
 
Dispatcheroperator= (const Dispatcher &)=delete
 
 Dispatcher ()=default
 
virtual ~Dispatcher ()
 
bool dispatchNext (Controller &controller, const std::string &parentMountPath)
 

Private Member Functions

bool dispatch (express::Controller &controller, const std::string &parentMountPath, const express::MountPoint &mountPoint) override
 

Private Attributes

const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> lambda
 

Detailed Description

Definition at line 40 of file ApplicationDispatcher.h.

Constructor & Destructor Documentation

◆ ApplicationDispatcher()

express::dispatcher::ApplicationDispatcher::ApplicationDispatcher ( const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> & lambda)
explicit

Definition at line 33 of file ApplicationDispatcher.cpp.

35 : lambda(lambda) {
36 }
const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> lambda

References ApplicationDispatcher().

Referenced by ApplicationDispatcher().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ dispatch()

bool express::dispatcher::ApplicationDispatcher::dispatch ( express::Controller & controller,
const std::string & parentMountPath,
const express::MountPoint & mountPoint )
overrideprivatevirtual

Implements express::Dispatcher.

Definition at line 38 of file ApplicationDispatcher.cpp.

40 {
41 bool dispatched = false;
42
43 if ((controller.getFlags() & Controller::NEXT) == 0) {
44 const std::string absoluteMountPath = path_concat(parentMountPath, mountPoint.relativeMountPath);
45 if (((controller.getRequest()->path.rfind(absoluteMountPath, 0) == 0 ||
46 controller.getRequest()->url.rfind(absoluteMountPath, 0) == 0) &&
47 mountPoint.method == "use") ||
48 ((absoluteMountPath == controller.getRequest()->url || absoluteMountPath == controller.getRequest()->path ||
49 checkForUrlMatch(absoluteMountPath, controller.getRequest()->url)) &&
50 (controller.getRequest()->method == mountPoint.method || mountPoint.method == "all"))) {
51 dispatched = true;
52
53 if (hasResult(absoluteMountPath)) {
54 setParams(absoluteMountPath, *controller.getRequest());
55 }
56
57 lambda(controller.getRequest(), controller.getResponse());
58 }
59 }
60
61 return dispatched;
62 }
const std::shared_ptr< Request > & getRequest()
int getFlags() const
const std::shared_ptr< Response > & getResponse()
bool checkForUrlMatch(const std::string &cpath, const std::string &reqpath)
void setParams(const std::string &cpath, express::Request &req)
bool hasResult(const std::string &cpath)
std::string path_concat(const std::vector< std::string > &stringvec)
std::string method
Definition MountPoint.h:34
std::string relativeMountPath
Definition MountPoint.h:35

References express::Controller::getFlags(), and express::Controller::NEXT.

Here is the call graph for this function:

Member Data Documentation

◆ lambda

const std::function<void(const std::shared_ptr<Request>&, const std::shared_ptr<Response>&)> express::dispatcher::ApplicationDispatcher::lambda
private

Definition at line 48 of file ApplicationDispatcher.h.


The documentation for this class was generated from the following files: