2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "express/middleware/VHost.h"
44#ifndef DOXYGEN_SHOULD_SKIP_THIS
50namespace express::middleware {
58 if (host.front() ==
'[') {
59 if (
auto rb = host.find(
']'); rb != std::string_view::npos) {
60 return host.substr(1, rb - 1);
67 if (
auto pos = host.rfind(
':'); pos != std::string_view::npos) {
68 if (host.find(
':') == pos) {
70 return host.substr(0, pos);
81 use(
"/", [&host
= this->host]
MIDDLEWARE(req, res, next) {
92 static std::map<std::string, std::shared_ptr<
class VHost>> vHostMiddlewares;
94 if (!vHostMiddlewares.contains(host)) {
95 vHostMiddlewares[host] = std::shared_ptr<
VHost>(
new VHost(host
));
98 return *vHostMiddlewares[host];
102 class VHost& VHost(
const std::string& host) {
#define MIDDLEWARE(req, res, next)
void operator()(const std::string &how="") const
const std::string & get(const std::string &key, int i=0) const
VHost(const std::string &host)
static class VHost & instance(const std::string &host)
static std::string_view hostWithoutPort(std::string_view host)