kong.router

Router module.

A set of functions to access the routing properties of the request.

kong.router.get_route()

Returns the current route entity. The request is matched against this route.

Phases

  • access, header_filter, response, body_filter, log

Returns

  • table: The route entity.

Usage

  1. local route = kong.router.get_route()
  2. local protocols = route.protocols

kong.router.get_service()

Returns the current service entity. The request is targeted to this upstream service.

Phases

  • access, header_filter, response, body_filter, log

Returns

  • table: The service entity.

Usage

  1. if kong.router.get_service() then
  2. -- routed by route & service entities
  3. else
  4. -- routed by a route without a service
  5. end