SNode.C
Loading...
Searching...
No Matches
express::middleware::StaticMiddleware Class Reference

#include <StaticMiddleware.h>

Inheritance diagram for express::middleware::StaticMiddleware:
Collaboration diagram for express::middleware::StaticMiddleware:

Public Member Functions

 StaticMiddleware (const StaticMiddleware &)=delete
StaticMiddlewareoperator= (const StaticMiddleware &)=delete
StaticMiddlewaresetIndex (const std::string &index)
StaticMiddlewareclearStdHeaders ()
StaticMiddlewaresetStdHeaders (const std::map< std::string, std::string > &stdHeaders)
StaticMiddlewareappendStdHeaders (const std::map< std::string, std::string > &stdHeaders)
StaticMiddlewareappendStdHeaders (const std::string &field, const std::string &value)
StaticMiddlewareappendStdCookie (const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
StaticMiddlewareafterResponse (web::http::ConnectionState connectionState)
Public Member Functions inherited from express::Router
 Router ()
 Router (const Router &)=default
const RoutersetStrictRouting (bool strictRouting=true) const
const RoutersetCaseInsensitiveRouting (bool caseInsensitiveRouting=true) const
const RoutersetMergeParams (bool mergeParams=true) const
std::list< std::string > getRoutes () const
Routeuse (const Router &router) const
Routeuse (const std::string &relativeMountPath, const Router &router) const
Routeuse (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeuse (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeuse (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routeuse (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routeuse (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeuse (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeuse (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeuse (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routeall (const Router &router) const
Routeall (const std::string &relativeMountPath, const Router &router) const
Routeall (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeall (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeall (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routeall (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routeall (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeall (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeall (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeall (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routeget (const Router &router) const
Routeget (const std::string &relativeMountPath, const Router &router) const
Routeget (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeget (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeget (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routeget (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routeget (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeget (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeget (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeget (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routeput (const Router &router) const
Routeput (const std::string &relativeMountPath, const Router &router) const
Routeput (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeput (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeput (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routeput (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routeput (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeput (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeput (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeput (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routepost (const Router &router) const
Routepost (const std::string &relativeMountPath, const Router &router) const
Routepost (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routepost (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routepost (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routepost (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routepost (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routepost (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routepost (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routepost (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routedel (const Router &router) const
Routedel (const std::string &relativeMountPath, const Router &router) const
Routedel (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routedel (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routedel (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routedel (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routedel (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routedel (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routedel (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routedel (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routeconnect (const Router &router) const
Routeconnect (const std::string &relativeMountPath, const Router &router) const
Routeconnect (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeconnect (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeconnect (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routeconnect (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routeconnect (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeconnect (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeconnect (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeconnect (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routeoptions (const Router &router) const
Routeoptions (const std::string &relativeMountPath, const Router &router) const
Routeoptions (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeoptions (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routeoptions (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routeoptions (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routeoptions (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeoptions (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeoptions (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routeoptions (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routetrace (const Router &router) const
Routetrace (const std::string &relativeMountPath, const Router &router) const
Routetrace (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routetrace (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routetrace (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routetrace (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routetrace (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routetrace (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routetrace (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routetrace (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routepatch (const Router &router) const
Routepatch (const std::string &relativeMountPath, const Router &router) const
Routepatch (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routepatch (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routepatch (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routepatch (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routepatch (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routepatch (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routepatch (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routepatch (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
Routehead (const Router &router) const
Routehead (const std::string &relativeMountPath, const Router &router) const
Routehead (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routehead (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Routehead (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
Routehead (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda) const
template<typename... Lambdas>
Routehead (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routehead (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routehead (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const
template<typename... Lambdas>
Routehead (const std::string &relativeMountPath, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, Next &)> &lambda, Lambdas... lambdas) const

Protected Member Functions

 StaticMiddleware (const std::string &root, bool fallThrough)

Static Protected Member Functions

static class StaticMiddlewareinstance (const std::string &root, bool fallThrough)

Private Attributes

std::string root
std::string index
bool fallThrough
std::map< std::string, std::string > stdHeaders = {{"Cache-Control", "public, max-age=0"}, {"Accept-Ranges", "bytes"}}
std::map< std::string, web::http::CookieOptionsstdCookies
web::http::ConnectionState defaultConnectionState = web::http::ConnectionState::Default

Friends

class StaticMiddleware & StaticMiddleware (const std::string &root, bool fallThrough=true)

Additional Inherited Members

Protected Attributes inherited from express::Router
std::shared_ptr< RootRouterootRoute = nullptr

Detailed Description

Definition at line 59 of file StaticMiddleware.h.

Constructor & Destructor Documentation

◆ StaticMiddleware() [1/2]

express::middleware::StaticMiddleware::StaticMiddleware ( const StaticMiddleware & )
delete

◆ StaticMiddleware() [2/2]

express::middleware::StaticMiddleware::StaticMiddleware ( const std::string & root,
bool fallThrough )
explicitprotected

Definition at line 58 of file StaticMiddleware.cpp.

59 : root(root)
60 , index("index.html")
62 setStrictRouting(false);
63
64 use(
65 [&stdHeaders = this->stdHeaders,
66 &stdCookies = this->stdCookies,
67 &connectionState = this->defaultConnectionState,
68 &fallThrough = this->fallThrough] MIDDLEWARE(req, res, next) {
69 LOG(DEBUG) << res->getSocketContext()->getSocketConnection()->getConnectionName() << " Express " << req->method;
70
71 if (req->method != "GET") {
72 if (fallThrough) {
73 next("route");
74 } else {
75 res->sendStatus(405, "Unsupported method: " + req->method + "\n");
76 }
77 } else {
78 if (connectionState == web::http::ConnectionState::Close) {
79 res->set("Connection", "close");
80 } else if (connectionState == web::http::ConnectionState::Keep) {
81 res->set("Connection", "keep-alive");
82 }
83 res->set(stdHeaders);
84
85 for (auto& [value, options] : stdCookies) {
86 res->cookie(value, options.getValue(), options.getOptions());
87 }
88
89 next();
90 }
91 },
92 [&index = this->index] MIDDLEWARE(req, res, next) {
93 if (req->path == "/") {
94 if (index.empty()) {
95 res->status(404).send("Unsupported resource: " + req->url + "\n");
96 } else {
97 LOG(INFO) << res->getSocketContext()->getSocketConnection()->getConnectionName()
98 << " Express StaticMiddleware Redirecting: " << req->url << " -> "
99 << req->originalPath +
100 (!req->originalPath.empty() && req->originalPath.back() != '/' && index.front() != '/' ? "/"
101 : "") +
102 index;
103 res->redirect(
104 308,
105 req->originalPath +
106 (!req->originalPath.empty() && req->originalPath.back() != '/' && index.front() != '/' ? "/" : "") + index);
107 }
108 } else {
109 next();
110 }
111 },
112 [&root = this->root, &fallThrough = this->fallThrough] MIDDLEWARE(req, res, next) {
113 const std::string decodedPath = httputils::url_decode(req->path);
114 res->sendFile(root + decodedPath, [&root, decodedPath, req, res, &next, &fallThrough](int ret) {
115 if (ret == 0) {
116 LOG(INFO) << res->getSocketContext()->getSocketConnection()->getConnectionName()
117 << " Express StaticMiddleware: GET " << req->url + " -> " << root + decodedPath;
118 } else {
119 PLOG(ERROR) << res->getSocketContext()->getSocketConnection()->getConnectionName() << " Express StaticMiddleware "
120 << req->url + " -> " << root + decodedPath;
121
122 if (fallThrough) {
123 next();
124 } else {
125 res->status(404).send("Unsupported resource: " + req->url + "\n");
126 }
127 }
128 });
129 });
130 }
#define LOG(level)
Definition Logger.h:148
#define PLOG(level)
Definition Logger.h:152
#define MIDDLEWARE(req, res, next)
Definition Router.h:63
const Router & setStrictRouting(bool strictRouting=true) const
Definition Router.cpp:78
Route & options(const Router &router) const
Definition Router.cpp:107
Route & use(const Router &router) const
Definition Router.cpp:100
std::map< std::string, web::http::CookieOptions > stdCookies
web::http::ConnectionState defaultConnectionState
std::map< std::string, std::string > stdHeaders
std::string url_decode(const std::string &text)

References web::http::Close, express::Response::cookie(), logger::DEBUG, logger::ERROR, fallThrough, core::socket::stream::SocketConnection::getConnectionName(), web::http::CookieOptions::getOptions(), core::socket::stream::SocketContext::getSocketConnection(), express::Response::getSocketContext(), web::http::CookieOptions::getValue(), index, logger::INFO, web::http::Keep, logger::LogMessage::LogMessage(), express::Request::method, express::Next::operator()(), express::Request::originalPath, express::Request::path, express::Response::redirect(), root, express::Response::send(), express::Response::sendFile(), express::Response::sendStatus(), express::Response::set(), express::Response::set(), express::Router::setStrictRouting(), express::Response::status(), express::Request::url, and httputils::url_decode().

Referenced by instance().

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

Member Function Documentation

◆ afterResponse()

class StaticMiddleware & express::middleware::StaticMiddleware::afterResponse ( web::http::ConnectionState connectionState)

Definition at line 170 of file StaticMiddleware.cpp.

170 {
171 this->defaultConnectionState = connectionState;
172
173 return *this;
174 }

References defaultConnectionState.

◆ appendStdCookie()

class StaticMiddleware & express::middleware::StaticMiddleware::appendStdCookie ( const std::string & name,
const std::string & value,
const std::map< std::string, std::string > & options = {} )

Definition at line 162 of file StaticMiddleware.cpp.

164 {
165 this->stdCookies.insert({name, web::http::CookieOptions(value, options)});
166
167 return *this;
168 }

References web::http::CookieOptions::CookieOptions(), and stdCookies.

Here is the call graph for this function:

◆ appendStdHeaders() [1/2]

class StaticMiddleware & express::middleware::StaticMiddleware::appendStdHeaders ( const std::map< std::string, std::string > & stdHeaders)

Definition at line 150 of file StaticMiddleware.cpp.

150 {
151 this->stdHeaders.insert(stdHeaders.begin(), stdHeaders.end());
152
153 return *this;
154 }

References stdHeaders.

◆ appendStdHeaders() [2/2]

class StaticMiddleware & express::middleware::StaticMiddleware::appendStdHeaders ( const std::string & field,
const std::string & value )

Definition at line 156 of file StaticMiddleware.cpp.

156 {
157 this->stdHeaders[field] = value;
158
159 return *this;
160 }

References stdHeaders.

◆ clearStdHeaders()

class StaticMiddleware & express::middleware::StaticMiddleware::clearStdHeaders ( )

Definition at line 138 of file StaticMiddleware.cpp.

138 {
139 this->stdHeaders.clear();
140
141 return *this;
142 }

References stdHeaders.

◆ instance()

class StaticMiddleware & express::middleware::StaticMiddleware::instance ( const std::string & root,
bool fallThrough )
staticprotected

Definition at line 176 of file StaticMiddleware.cpp.

176 {
177 // Keep all created static middlewares alive
178 static std::map<const std::string, std::shared_ptr<class StaticMiddleware>> staticMiddlewares;
179
180 if (!staticMiddlewares.contains(root)) {
181 staticMiddlewares[root] = std::shared_ptr<StaticMiddleware>(new StaticMiddleware(root, fallThrough));
182 }
183
184 return *staticMiddlewares[root];
185 }
StaticMiddleware(const StaticMiddleware &)=delete

References StaticMiddleware().

Referenced by StaticMiddleware.

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

◆ operator=()

StaticMiddleware & express::middleware::StaticMiddleware::operator= ( const StaticMiddleware & )
delete

◆ setIndex()

class StaticMiddleware & express::middleware::StaticMiddleware::setIndex ( const std::string & index)

Definition at line 132 of file StaticMiddleware.cpp.

132 {
133 this->index = index;
134
135 return *this;
136 }

References index.

◆ setStdHeaders()

class StaticMiddleware & express::middleware::StaticMiddleware::setStdHeaders ( const std::map< std::string, std::string > & stdHeaders)

Definition at line 144 of file StaticMiddleware.cpp.

144 {
145 this->stdHeaders = stdHeaders;
146
147 return *this;
148 }

References stdHeaders.

◆ StaticMiddleware

class StaticMiddleware & StaticMiddleware ( const std::string & root,
bool fallThrough = true )
friend

Definition at line 188 of file StaticMiddleware.cpp.

188 {
190 }
static class StaticMiddleware & instance(const std::string &root, bool fallThrough)

References instance().

Member Data Documentation

◆ defaultConnectionState

web::http::ConnectionState express::middleware::StaticMiddleware::defaultConnectionState = web::http::ConnectionState::Default
private

Definition at line 85 of file StaticMiddleware.h.

Referenced by afterResponse().

◆ fallThrough

bool express::middleware::StaticMiddleware::fallThrough
private

Definition at line 82 of file StaticMiddleware.h.

Referenced by StaticMiddleware().

◆ index

std::string express::middleware::StaticMiddleware::index
private

Definition at line 81 of file StaticMiddleware.h.

Referenced by setIndex(), and StaticMiddleware().

◆ root

std::string express::middleware::StaticMiddleware::root
private

Definition at line 80 of file StaticMiddleware.h.

Referenced by StaticMiddleware().

◆ stdCookies

std::map<std::string, web::http::CookieOptions> express::middleware::StaticMiddleware::stdCookies
private

Definition at line 84 of file StaticMiddleware.h.

Referenced by appendStdCookie().

◆ stdHeaders

std::map<std::string, std::string> express::middleware::StaticMiddleware::stdHeaders = {{"Cache-Control", "public, max-age=0"}, {"Accept-Ranges", "bytes"}}
private

Definition at line 83 of file StaticMiddleware.h.

83{{"Cache-Control", "public, max-age=0"}, {"Accept-Ranges", "bytes"}};

Referenced by appendStdHeaders(), appendStdHeaders(), clearStdHeaders(), and setStdHeaders().


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