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 ¶
- type AuthenticatedCredential
- type Client
- func (c Client) Authenticate(consumer *entities.Consumer, credential *AuthenticatedCredential) error
- func (c Client) GetConsumer() (consumer entities.Consumer, err error)
- func (c Client) GetCredential() (cred AuthenticatedCredential, err error)
- func (c Client) GetForwardedIp() (string, error)
- func (c Client) GetForwardedPort() (int, error)
- func (c Client) GetIp() (ip string, err error)
- func (c Client) GetPort() (int, error)
- func (c Client) GetProtocol(allow_terminated bool) (string, error)
- func (c Client) LoadConsumer(consumer_id string, by_username bool) (consumer entities.Consumer, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticatedCredential ¶
type Client ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.