SNode.C
Loading...
Searching...
No Matches
express::middleware Namespace Reference

Classes

class  StaticMiddleware
class  JsonMiddleware
class  BasicAuthentication
class  VHost
class  VerboseRequest

Functions

class StaticMiddleware & StaticMiddleware (const std::string &root)
class JsonMiddleware & JsonMiddleware ()
class BasicAuthentication & BasicAuthentication (const std::string &userName, const std::string &password, const std::string &realm)
class VHost & VHost (const std::string &host)
class VerboseRequest & VerboseRequest (VerboseRequest::Details details=VerboseRequest::W_ALL)
static std::string_view hostWithoutPort (std::string_view host)

Function Documentation

◆ BasicAuthentication()

class BasicAuthentication & express::middleware::BasicAuthentication ( const std::string & userName,
const std::string & password,
const std::string & realm )

Definition at line 86 of file BasicAuthentication.cpp.

86 {
87 return BasicAuthentication::instance(userName, password, realm);
88 }
static class BasicAuthentication & instance(const std::string &userName, const std::string &password, const std::string &realm)

◆ hostWithoutPort()

std::string_view express::middleware::hostWithoutPort ( std::string_view host)
static

Definition at line 52 of file VHost.cpp.

52 {
53 if (host.empty()) {
54 return host;
55 }
56
57 // Bracketed IPv6: "[::1]:8080" -> "::1"
58 if (host.front() == '[') {
59 if (auto rb = host.find(']'); rb != std::string_view::npos) {
60 return host.substr(1, rb - 1);
61 }
62
63 return host; // malformed, just return as-is
64 }
65
66 // Find last ':'; if there is exactly one colon, treat it as host:port
67 if (auto pos = host.rfind(':'); pos != std::string_view::npos) {
68 if (host.find(':') == pos) { // only one colon -> host:port
69
70 return host.substr(0, pos); // "localhost:8080" -> "localhost"
71 }
72
73 return host; // multiple colons (likely raw IPv6 without brackets) -> keep whole
74 }
75
76 return host; // no port
77 }

Referenced by express::middleware::VHost::VHost().

Here is the caller graph for this function:

◆ JsonMiddleware()

class JsonMiddleware & express::middleware::JsonMiddleware ( )

Definition at line 84 of file JsonMiddleware.cpp.

84 {
86 }
static class JsonMiddleware & instance()

◆ StaticMiddleware()

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

Definition at line 173 of file StaticMiddleware.cpp.

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

◆ VerboseRequest()

class VerboseRequest & express::middleware::VerboseRequest ( VerboseRequest::Details details = VerboseRequest::W_ALL)

Definition at line 76 of file VerboseRequest.cpp.

76 {
77 static std::shared_ptr<class VerboseRequest> verboseRequest = nullptr;
78
79 if (verboseRequest == nullptr) {
80 verboseRequest = std::shared_ptr<class VerboseRequest>(new class VerboseRequest(details));
81 }
82
83 return *verboseRequest;
84 }
class VerboseRequest & VerboseRequest(VerboseRequest::Details details=VerboseRequest::W_ALL)

◆ VHost()

class VHost & express::middleware::VHost ( const std::string & host)

Definition at line 102 of file VHost.cpp.

102 {
103 return VHost::instance(host);
104 }
static class VHost & instance(const std::string &host)
Definition VHost.cpp:90