matchesPath

fun matchesPath(configPath: String, requestPath: String): Boolean

Checks if a request path matches a configured endpoint path pattern.

This method splits both paths into segments and compares them one by one. Segments enclosed in curly braces ({ and }) in the config path are treated as parameters and match any value in the request path.

Algorithm

  1. Split both paths by / separator

  2. Filter out empty segments (from leading/trailing slashes)

  3. Check if segment counts match (if not, no match)

  4. Compare each segment pair:

    • If config segment is a parameter ({...}), it matches any request value

    • Otherwise, require exact string match (case-sensitive)

  5. Return true only if all segments match

Performance

  • Time Complexity: O(n) where n is the number of path segments

  • Space Complexity: O(n) for storing segment lists

  • Typically very fast as API paths are short (usually < 10 segments)

Return

true if the request path matches the pattern, false otherwise

Parameters

configPath

The configured endpoint path pattern (may contain {parameters})

requestPath

The actual incoming request path