kong.router

Uses: Kong Gateway

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

local route = kong.router.get_route()
local protocols = route.protocols
Copied to clipboard!

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

if kong.router.get_service() then
  -- routed by route & service entities
else
  -- routed by a route without a service
end
Copied to clipboard!

Did this doc help?

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!