1
#pragma once
2

            
3
#include "envoy/config/typed_config.h"
4

            
5
#include "source/common/common/logger.h"
6

            
7
#include "absl/status/statusor.h"
8
#include "absl/strings/string_view.h"
9

            
10
namespace Envoy {
11
namespace Router {
12

            
13
/**
14
 * Decides if the target route path matches the provided pattern.
15
 * Subclassing Logger::Loggable so that implementations can log details.
16
 */
17
class PathMatcher : Logger::Loggable<Logger::Id::router> {
18
public:
19
8567
  PathMatcher() = default;
20
8567
  virtual ~PathMatcher() = default;
21

            
22
  /**
23
   * Returns true if path matches the pattern.
24
   *
25
   * @param path the path to be matched
26
   * @return true if path matches the pattern.
27
   */
28
  virtual bool match(absl::string_view path) const PURE;
29

            
30
  /**
31
   * @return the match uri_template.
32
   */
33
  virtual absl::string_view uriTemplate() const PURE;
34

            
35
  /**
36
   * @return the name of the path matcher.
37
   */
38
  virtual absl::string_view name() const PURE;
39
};
40

            
41
using PathMatcherSharedPtr = std::shared_ptr<PathMatcher>;
42

            
43
/**
44
 * Factory for PathMatcher.
45
 */
46
class PathMatcherFactory : public Envoy::Config::TypedFactory {
47
public:
48
  ~PathMatcherFactory() override = default;
49

            
50
  /**
51
   * @param config contains the proto stored in TypedExtensionConfig.
52
   * @return an PathMatcherSharedPtr.
53
   */
54
  virtual absl::StatusOr<PathMatcherSharedPtr>
55
  createPathMatcher(const Protobuf::Message& config) PURE;
56

            
57
  ProtobufTypes::MessagePtr createEmptyConfigProto() override PURE;
58

            
59
  /**
60
   * @return the name of the path matcher to be created.
61
   */
62
  std::string name() const override PURE;
63

            
64
  /**
65
   * @return the category of the path matcher to be created.
66
   */
67
2629
  std::string category() const override { return "envoy.path.match"; }
68
};
69

            
70
} // namespace Router
71
} // namespace Envoy