request

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: 3 Imported by: 1

Documentation

Overview

Manipulation of the request to the Service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	bridge.PdkBridge
}

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

func (Request) AddHeader

func (r Request) AddHeader(name string, value string) error

kong.ServiceRequest.AddHeader() adds a request header with the given value to the request to the Service. Unlike kong.ServiceRequest.SetHeader(), this function will not remove any existing headers with the same name. Instead, several occurences of the header will be present in the request. The order in which headers are added is retained.

func (Request) ClearHeader

func (r Request) ClearHeader(name string) error

kong.ServiceRequest.ClearHeader() removes all occurrences of the specified header in the request to the Service.

func (Request) SetHeader

func (r Request) SetHeader(name string, value string) error

kong.ServiceRequest.SetHeader() sets a header in the request to the Service with the given value. Any existing header with the same name will be overridden.

If the header argument is "host" (case-insensitive), then this will also set the SNI of the request to the Service.

func (Request) SetHeaders

func (r Request) SetHeaders(headers map[string][]string) error

kong.ServiceRequest.SetHeaders() sets the headers of the request to the Service. Unlike kong.ServiceRequest.SetHeader(), the headers argument must be a map in which each key is a string (corresponding to a header’s name), and each value an array of strings.

The resulting headers are produced in lexicographical order. The order of entries with the same name is retained.

This function overrides any existing header bearing the same name as those specified in the headers argument. Other headers remain unchanged.

If the "Host" header is set (case-insensitive), then this is will also set the SNI of the request to the Service.

func (Request) SetMethod

func (r Request) SetMethod(method string) error

kong.ServiceRequest.SetMethod() sets the HTTP method for the request to the service.

Supported method values are: "GET", "HEAD", "PUT", "POST", "DELETE", "OPTIONS", "MKCOL", "COPY", "MOVE", "PROPFIND", "PROPPATCH", "LOCK", "UNLOCK", "PATCH", "TRACE".

func (Request) SetPath

func (r Request) SetPath(path string) error

kong.ServiceRequest.SetPath() sets the path component for the request to the service. It is not normalized in any way and should not include the querystring.

func (Request) SetQuery

func (r Request) SetQuery(query map[string][]string) error

kong.ServiceRequest.SetQuery() sets the querystring of the request to the Service.

Unlike kong.ServiceRequest.SetRawQuery(), the query argument must be a map in which each key is a string (corresponding to an arguments name), and each value is either an array of strings or booleans. Additionally, all string values will be URL-encoded.

The resulting querystring will contain keys in their lexicographical order. The order of entries within the same key is retained.

If further control of the querystring generation is needed, a raw querystring can be given as a string with kong.ServiceRequest.SetRawQuery().

func (Request) SetRawBody

func (r Request) SetRawBody(body string) error

kong.ServiceRequest SetRawBody() sets the body of the request to the Service.

The body argument must be a string and will not be processed in any way. This function also sets the Content-Length header appropriately. To set an empty body, one can give an empty string "" to this function.

For a higher-level function to set the body based on the request content type, see kong.ServiceRequest.SetBody().

func (Request) SetRawQuery

func (r Request) SetRawQuery(query string) error

kong.ServiceRequest.SetRawQuery() sets the querystring of the request to the Service. The query argument is a string (without the leading ? character), and will not be processed in any way.

For a higher-level function to set the query string from a ???? of arguments, see kong.ServiceRequest.SetQuery().

func (Request) SetScheme

func (r Request) SetScheme(scheme string) error

kong.ServiceRequest.SetScheme() sets the protocol to use when proxying the request to the Service. Supported values are "http" or "https".

Jump to

Keyboard shortcuts

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