Lines Matching refs:pattern
38 bool serve_mux::handle(std::string pattern, request_cb cb) { in handle() argument
39 if (pattern.empty() || !cb) { in handle()
43 auto it = mux_.find(pattern); in handle()
50 if (pattern.size() >= 2 && pattern.back() == '/') { in handle()
51 auto redirect_pattern = pattern.substr(0, pattern.size() - 1); in handle()
55 if (pattern[0] == '/') { in handle()
56 path = pattern; in handle()
59 path = pattern.substr(pattern.find('/')); in handle()
65 pattern}); in handle()
68 false, redirect_handler(301, std::move(path)), pattern}; in handle()
72 mux_.emplace(pattern, handler_entry{true, std::move(cb), pattern}); in handle()
107 bool path_match(const std::string &pattern, const std::string &path) { in path_match() argument
108 if (pattern.back() != '/') { in path_match()
109 return pattern == path; in path_match()
111 return util::starts_with(path, pattern); in path_match()
119 auto &pattern = kv.first; in match() local
120 if (!path_match(pattern, path)) { in match()
123 if (!ent || best < pattern.size()) { in match()
124 best = pattern.size(); in match()