Skip to content

starts_with#

The starts_with() function checks if a given value starts with a specified prefix.

Syntax#

starts_with(value, prefix)

Parameters#

  • value: The value to check (field name, bytes)
  • prefix: The prefix to match against (literal bytes)

Return Value#

Returns a boolean value: true if the value starts with the specified prefix, false otherwise.

Example#

starts_with(http.request.uri.path, "/api/") // Checks if the URI path starts with "/api/"

Use Cases#

  • Routing requests based on URL path prefixes
  • Identifying specific types of requests or resources
  • Implementing path-based access control