Line data Source code
1 : #pragma once 2 : 3 : #include <string> 4 : 5 : #include "envoy/extensions/path/match/uri_template/v3/uri_template_match.pb.h" 6 : #include "envoy/router/path_matcher.h" 7 : 8 : #include "source/extensions/path/uri_template_lib/uri_template.h" 9 : 10 : #include "absl/status/statusor.h" 11 : #include "absl/strings/string_view.h" 12 : 13 : namespace Envoy { 14 : namespace Extensions { 15 : namespace UriTemplate { 16 : namespace Match { 17 : 18 : const absl::string_view NAME = "envoy.path.match.uri_template.uri_template_matcher"; 19 : 20 : /** 21 : * UriTemplateMatcher allows matching based on uri templates. 22 : * Examples of several uri templates types are below: 23 : * Variable: /foo/bar/{var} 24 : * Will match any path that starts with /foo/bar and has one additional segment 25 : * Literal: /foo/bar/goo 26 : * Will match only a path of /foo/bar/goo 27 : */ 28 : class UriTemplateMatcher : public Router::PathMatcher { 29 : public: 30 : explicit UriTemplateMatcher( 31 : const envoy::extensions::path::match::uri_template::v3::UriTemplateMatchConfig& config) 32 60 : : path_template_(config.path_template()) {} 33 : 34 : // Router::PathMatcher 35 : bool match(absl::string_view path) const override; 36 : absl::string_view uriTemplate() const override; 37 44 : absl::string_view name() const override { return NAME; } 38 : 39 : private: 40 : const std::string path_template_; 41 : }; 42 : 43 : } // namespace Match 44 : } // namespace UriTemplate 45 : } // namespace Extensions 46 : } // namespace Envoy