LCOV - code coverage report
Current view: top level - envoy/router - path_matcher.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 3 4 75.0 %
Date: 2024-01-05 06:35:25 Functions: 3 4 75.0 %

          Line data    Source code
       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         161 :   PathMatcher() = default;
      20         161 :   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           0 :   ~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         112 :   std::string category() const override { return "envoy.path.match"; }
      68             : };
      69             : 
      70             : } // namespace Router
      71             : } // namespace Envoy

Generated by: LCOV version 1.15