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
 
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)
 

Static Protected Member Functions

static class StaticMiddlewareinstance (const std::string &root)
 

Private Attributes

std::string root
 
std::string index
 
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 StaticMiddlewareStaticMiddleware (const std::string &root)
 

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)
explicitprotected

Definition at line 57 of file StaticMiddleware.cpp.

58 : root(root)
59 , index("index.html") {
60 setStrictRouting(false);
61
62 use(
63 [&stdHeaders = this->stdHeaders, &stdCookies = this->stdCookies, &connectionState = this->defaultConnectionState] MIDDLEWARE(
64 req, res, next) {
65 LOG(DEBUG) << res->getSocketContext()->getSocketConnection()->getConnectionName() << " Express " << req->method;
66
67 if (req->method == "GET") {
68 if (connectionState == web::http::ConnectionState::Close) {
69 res->set("Connection", "close");
70 } else if (connectionState == web::http::ConnectionState::Keep) {
71 res->set("Connection", "keep-alive");
72 }
73 res->set(stdHeaders);
74
75 for (auto& [value, options] : stdCookies) {
76 res->cookie(value, options.getValue(), options.getOptions());
77 }
78 next();
79 } else {
80 res->sendStatus(405, "Unsupported method: " + req->method + "\n");
81 }
82 },
83 [&index = this->index] MIDDLEWARE(req, res, next) {
84 if (req->url.ends_with("/")) {
85 if (!index.empty()) {
86 LOG(INFO) << res->getSocketContext()->getSocketConnection()->getConnectionName()
87 << " Express StaticMiddleware Redirecting: " << req->url << " -> " << req->url + index;
88 res->redirect(308, req->url + index);
89 } else {
90 res->status(404).send("Unsupported resource: " + req->url + "\n");
91 }
92 } else {
93 next();
94 }
95 },
96 [&root = this->root] MIDDLEWARE(req, res, next) {
97 const bool fileAllowed = true;
98
99 if (fileAllowed) {
100 res->sendFile(root + req->url, [&root, req, res](int ret) {
101 if (ret == 0) {
102 LOG(INFO) << res->getSocketContext()->getSocketConnection()->getConnectionName()
103 << " Express StaticMiddleware: GET " << req->url + " -> " << root + req->url;
104 } else {
105 PLOG(ERROR) << res->getSocketContext()->getSocketConnection()->getConnectionName()
106 << " Express StaticMiddleware " << req->url + " -> " << root + req->url;
107
108 res->sendStatus(404);
109 }
110 });
111 } else {
112 next();
113 }
114 });
115 }
#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:101
Route & use(const Router &router) const
Definition Router.cpp:94
std::map< std::string, web::http::CookieOptions > stdCookies
web::http::ConnectionState defaultConnectionState
std::map< std::string, std::string > stdHeaders

References web::http::Close, express::Response::cookie(), core::socket::stream::SocketConnection::getConnectionName(), web::http::CookieOptions::getOptions(), core::socket::stream::SocketContext::getSocketConnection(), express::Response::getSocketContext(), web::http::CookieOptions::getValue(), web::http::Keep, express::Request::method, express::Next::operator()(), express::Response::redirect(), express::Response::send(), express::Response::sendFile(), express::Response::sendStatus(), express::Response::set(), express::Response::set(), express::Router::setStrictRouting(), express::Response::status(), and express::Request::url.

Here is the call graph for this function:

Member Function Documentation

◆ afterResponse()

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

Definition at line 155 of file StaticMiddleware.cpp.

155 {
156 this->defaultConnectionState = connectionState;
157
158 return *this;
159 }

◆ 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 147 of file StaticMiddleware.cpp.

149 {
150 this->stdCookies.insert({name, web::http::CookieOptions(value, options)});
151
152 return *this;
153 }

References web::http::CookieOptions::CookieOptions().

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 135 of file StaticMiddleware.cpp.

135 {
136 this->stdHeaders.insert(stdHeaders.begin(), stdHeaders.end());
137
138 return *this;
139 }

◆ appendStdHeaders() [2/2]

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

Definition at line 141 of file StaticMiddleware.cpp.

141 {
142 this->stdHeaders[field] = value;
143
144 return *this;
145 }

◆ clearStdHeaders()

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

Definition at line 123 of file StaticMiddleware.cpp.

123 {
124 this->stdHeaders.clear();
125
126 return *this;
127 }

◆ instance()

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

Definition at line 161 of file StaticMiddleware.cpp.

161 {
162 // Keep all created static middlewares alive
163 static std::map<const std::string, std::shared_ptr<class StaticMiddleware>> staticMiddlewares;
164
165 if (!staticMiddlewares.contains(root)) {
166 staticMiddlewares[root] = std::shared_ptr<StaticMiddleware>(new StaticMiddleware(root));
167 }
168
169 return *staticMiddlewares[root];
170 }
StaticMiddleware(const StaticMiddleware &)=delete

◆ operator=()

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

◆ setIndex()

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

Definition at line 117 of file StaticMiddleware.cpp.

117 {
118 this->index = index;
119
120 return *this;
121 }

◆ setStdHeaders()

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

Definition at line 129 of file StaticMiddleware.cpp.

129 {
130 this->stdHeaders = stdHeaders;
131
132 return *this;
133 }

Friends And Related Symbol Documentation

◆ StaticMiddleware

class StaticMiddleware & StaticMiddleware ( const std::string &  root)
friend

Definition at line 173 of file StaticMiddleware.cpp.

173 {
175 }
static class StaticMiddleware & instance(const std::string &root)

Member Data Documentation

◆ defaultConnectionState

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

Definition at line 84 of file StaticMiddleware.h.

◆ index

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

Definition at line 81 of file StaticMiddleware.h.

◆ root

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

Definition at line 80 of file StaticMiddleware.h.

◆ stdCookies

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

Definition at line 83 of file StaticMiddleware.h.

◆ stdHeaders

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

Definition at line 82 of file StaticMiddleware.h.

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

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