client

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Overview

Client information module.

A set of functions to retrieve information about the client connecting to Kong in the context of a given request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticatedCredential

type AuthenticatedCredential struct {
	Id         string `json:"id"`
	ConsumerId string `json:"consumer_id"`
}

type Client

type Client struct {
	bridge.PdkBridge
}

Holds this module's functions. Accessible as `kong.Client`.

func (Client) Authenticate

func (c Client) Authenticate(consumer *entities.Consumer, credential *AuthenticatedCredential) error

kong.Client.Authenticate() sets the authenticated consumer and/or credential for the current request. While both consumer and credential can be nil, it is required that at least one of them exists. Otherwise this function will throw an error.

func (Client) GetConsumer

func (c Client) GetConsumer() (consumer entities.Consumer, err error)

kong.Client.GetConsumer() returns the consumer entity of the currently authenticated consumer. If not set yet, it returns nil.

func (Client) GetCredential

func (c Client) GetCredential() (cred AuthenticatedCredential, err error)

kong.Client.GetCredential() returns the credentials of the currently authenticated consumer. If not set yet, it returns nil.

func (Client) GetForwardedIp

func (c Client) GetForwardedIp() (string, error)

kong.Client.GetForwardedIp() returns the remote address of the client making the request. Unlike kong.client.get_ip, this function will consider forwarded addresses in cases when a load balancer is in front of Kong. Whether this function returns a forwarded address or not depends on several Kong configuration parameters:

  • trusted_ips
  • real_ip_header
  • real_ip_recursive

func (Client) GetForwardedPort

func (c Client) GetForwardedPort() (int, error)

kong.Client.GetForwardedPort() returns the remote port of the client making the request. Unlike kong.client.get_port, this function will consider forwarded ports in cases when a load balancer is in front of Kong. Whether this function returns a forwarded port or not depends on several Kong configuration parameters:

  • trusted_ips
  • real_ip_header
  • real_ip_recursive

func (Client) GetIp

func (c Client) GetIp() (ip string, err error)

kong.Client.GetIp() returns the remote address of the client making the request. This will always return the address of the client directly connecting to Kong. That is, in cases when a load balancer is in front of Kong, this function will return the load balancer’s address, and not that of the downstream client.

func (Client) GetPort

func (c Client) GetPort() (int, error)

kong.Client.GetPort() returns the remote port of the client making the request. This will always return the port of the client directly connecting to Kong. That is, in cases when a load balancer is in front of Kong, this function will return load balancer’s port, and not that of the downstream client.

func (Client) GetProtocol

func (c Client) GetProtocol(allow_terminated bool) (string, error)

kong.Client.GetProtocol() returns the protocol matched by the current route ("http", "https", "tcp" or "tls"), or nil, if no route has been matched, which can happen when dealing with erroneous requests.

func (Client) LoadConsumer

func (c Client) LoadConsumer(consumer_id string, by_username bool) (consumer entities.Consumer, err error)

kong.Client.LoadConsumer() returns the consumer from the datastore (or cache). Will look up the consumer by id, and optionally will do a second search by name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL