ballerina/http package

Primitives Summary

Type Description

Type Definitions

Type Values Description
AcceptEncoding NEVER | AUTO | ALWAYS
Algorithm NONE | LOAD_BALANCE | FAIL_OVER
CachingPolicy RFC_7234 | CACHE_CONTROL_AND_VALIDATORS
Chunking NEVER | AUTO | ALWAYS
CircuitState OPEN | HALF_OPEN | CLOSED
Represents Circuit Breaker circuit state.
Compression NEVER | AUTO | ALWAYS
HttpOperation PUT | POST | PATCH | OPTIONS | NONE | HEAD | GET | FORWARD | DELETE
HttpServiceLifeTime SINGLETON | SESSION | REQUEST | CONNECTION
KeepAlive NEVER | AUTO | ALWAYS
RedirectCode 308 | 307 | 305 | 304 | 303 | 302 | 301 | 300
TransferEncoding CHUNKING

Annotations

Name Attachement Points Data Type Description
ResourceConfig resource HttpResourceConfig Configurations annotation for an HTTP resource
ServiceConfig service HttpServiceConfig Configurations annotation for an HTTP service
WebSocketServiceConfig service WSServiceConfig Configurations annotation for a WebSocket service

Objects Summary

Object Description
AuthConfig AuthConfig record represents the authentication mechanism that HTTP client uses
AuthProvider Configuration for authentication providers
Authentication Representation of Authentication Config
Bucket
Represents Circuit Breaker sub window (Bucket).
CacheConfig CacheConfig record is used for providing the caching configurations necessary for the HTTP caching client.
CircuitBreakerConfig
Represents Circuit Breaker configuration.
CircuitBreakerInferredConfig
CircuitHealth
Represents Circuit health of the Circuit Breaker.
ClientEndpointConfig ClientEndpointConfig struct represents options to be used for HTTP client invocation
ConnectionThrottling This struct represents the options to be used for connection throttling
CorsConfig Configurations for CORS support
FailoverClientEndpointConfiguration
The configurations related to the failover client endpoint.
FailoverConfig Represents Failover connector retry configuration.
FailoverConnectorError Represents an error occurred in an function of the Failover connector.
FailoverInferredConfig
FilterResult Represents a filter result. This should be populated and returned by each request and response filter function
FollowRedirects FollowRedirects struct represents HTTP redirect related options to be used for HTTP client invocation
HttpConnectorError HttpConnectorError record represents an error occured during the HTTP client invocation
HttpResourceConfig Configuration for an HTTP resource
HttpServiceConfig Configuration for an HTTP service
HttpTimeoutError HttpTimeoutError record represents a timeout error occurred during service invocation.
KeyStore KeyStore record represents key store related options to be used for HTTP client/service invocation
ListenerAuthConfig Representation of AuthConfig
LoadBalanceClientEndpointConfiguration
The configurations related to the load balance client endpoint.
LoadBalanceConnectorError Represents an error occurred in an action of the Load Balance connector.
Local
Represents the details of local address.
PayloadError Represent all http payload related errors
Protocols Protocols record represents SSL/TLS protocol related options to be used for HTTP client/service invocation
ProxyConfig ProxyConfig struct represents proxy server configurations to be used for HTTP client invocation
Remote
Represents the details of remote address.
RequestLimits Request validation limits configuration for HTTP service endpoint
RetryConfig RetryConfig struct represents retry related options for HTTP client invocation
RollingWindow
Represents Circuit Breaker rolling window configuration.
SecureEndpointConfiguration Configuration for secure HTTP service endpoint
SecureSocket SecureSocket struct represents SSL/TLS options to be used for HTTP client invocation
ServiceEndpointConfiguration Configuration for HTTP service endpoint
ServiceOcspStapling OcspStapling record represents options related to check whether a certificate is revoked or not
ServiceSecureSocket SecureSocket struct represents SSL/TLS options to be used for HTTP service
TargetService Represents the configurations applied to a particular service.
TrustStore TrustStore record represents trust store related options to be used for HTTP client/service invocation
ValidateCert ValidateCert record represents options related to check whether a certificate is revoked or not
Versioning Configurations for service versioning
WSServiceConfig Configuration for a WebSocket service.
WebSocketClientEndpointConfig Configuration struct for WebSocket client connection
WebSocketUpgradeConfig

Endpoints Summary

Endpoint Description

Functions Summary

Return Type Function and Description
CallerActions createHttpCachingClient(string url, ClientEndpointConfig config, CacheConfig cacheConfig)
Creates an HTTP client capable of caching HTTP responses.
CallerActions createHttpClient(string uri, ClientEndpointConfig config)
CallerActions createHttpSecureClient(string url, ClientEndpointConfig config)
Creates an HTTP client capable of securing HTTP requests with authentication.
CallerActions createSimpleHttpClient(string uri, ClientEndpointConfig config)
string | error decode(string url, string charset)
Decodes the given URL
string | error encode(string url, string charset)
Encodes the given URL
string | null extractBasicAuthHeaderValue(Request req)
Extracts the basic authentication header value from the request
float getcurrentFailureRatio(CircuitHealth circuitHealth)
Calculate Failure at a given point.
Response | HttpConnectorError invokeEndpoint(string path, Request outRequest, HttpOperation requestAction, CallerActions httpClient)
(string,map) | error parseHeader(string headerValue)
Parse headerValue and return value with parameter map
resetBucketStats(CircuitHealth circuitHealth, int bucketId)
Reset the bucket values to default ones.
CallerActions roundRobin(LoadBalancer lb, CallerActions[] loadBalanceConfigArray)
CircuitState updateCircuitState(CircuitHealth circuitHealth, CircuitState currentStateValue, CircuitBreakerInferredConfig circuitBreakerInferredConfig)

Global Variables

Name Data Type Description
ACCEPTED_202 int

The HTTP response status code: 202 Accepted

ACCEPT_ENCODING_ALWAYS AcceptEncoding
ACCEPT_ENCODING_AUTO AcceptEncoding
ACCEPT_ENCODING_NEVER AcceptEncoding
AGE string

HTTP header key 'age'. Gives the current age of a cached HTTP response.

AUTHORIZATION string

HTTP header key 'authorization'

BAD_GATEWAY_502 int

The HTTP response status code: 502 Bad Gateway

BAD_REQUEST_400 int

The HTTP response status code: 400 Bad Request

CACHE_CONTROL string

HTTP header key 'cache-control'. Specifies the cache control directives required for the function of HTTP caches.

CACHE_CONTROL_AND_VALIDATORS CachingPolicy Used for configuring the caching behaviour. Setting the policy field in the CacheConfig struct allows the user to control the caching behaviour.
CB_CLOSED_STATE CircuitState
CB_HALF_OPEN_STATE CircuitState
CB_OPEN_STATE CircuitState
CHUNKING_ALWAYS Chunking
CHUNKING_AUTO Chunking
CHUNKING_NEVER Chunking
COMPRESSION_ALWAYS Compression
COMPRESSION_AUTO Compression
COMPRESSION_NEVER Compression
CONFLICT_409 int

The HTTP response status code: 409 Conflict

CONTENT_LENGTH string

HTTP header key 'content-length'. Specifies the size of the response body in bytes.

CONTINUE_100 int

The HTTP response status code: 100 Continue

CREATED_201 int

The HTTP response status code: 201 Created

DATE string

HTTP header key 'date'. The timestamp at the time the response was generated/received.

ETAG string

HTTP header key 'etag'. A finger print for a resource which is used by HTTP caches to identify whether a resource representation has changed.

EXPECT string

HTTP header key 'expect'. Specifies expectations to be fulfilled by the server.

EXPECTATION_FAILED_417 int

The HTTP response status code: 417 Expectation Failed

EXPIRES string

HTTP header key 'expires'. Specifies the time at which the response becomes stale.

FORBIDDEN_403 int

The HTTP response status code: 403 Forbidden

FOUND_302 int

The HTTP response status code: 302 Found

GATEWAY_TIMEOUT_504 int

The HTTP response status code: 504 Gateway Timeout

GONE_410 int

The HTTP response status code: 410 Gone

HTTP_DELETE HttpOperation
HTTP_FORWARD HttpOperation
HTTP_GET HttpOperation
HTTP_HEAD HttpOperation
HTTP_NONE HttpOperation
HTTP_OPTIONS HttpOperation
HTTP_PATCH HttpOperation
HTTP_POST HttpOperation
HTTP_PUT HttpOperation
HTTP_VERSION_NOT_SUPPORTED_505 int

The HTTP response status code: 505 HTTP Version Not Supported

IF_MATCH string

HTTP header key 'if-match'

IF_MODIFIED_SINCE string

HTTP header key 'if-modified-since'. Used when validating (with the origin server) whether a cached response is still valid. If the representation of the resource has modified since the timestamp in this field, a 304 response is returned.

IF_NONE_MATCH string

HTTP header key 'if-none-match'. Used when validating (with the origin server) whether a cached response is still valid. If the ETag provided in this field matches the representation of the requested resource, a 304 response is returned.

IF_RANGE string

HTTP header key 'if-range'

IF_UNMODIFIED_SINCE string

HTTP header key 'if-unmodified-since'

INTERNAL_SERVER_ERROR_500 int

The HTTP response status code: 500 Internal Server Error

LAST_MODIFIED string

HTTP header key 'last-modified'. The time at which the resource was last modified.

LENGTH_REQUIRED_411 int

The HTTP response status code: 411 Length Required

LOCATION string

HTTP header key 'location'. Indicates the URL to redirect a request to.

MAX_AGE string When used in requests, it implies that clients are not willing to accept responses whose age is greater than max-age. When used in responses, the response is to be considered stale after the specified number of seconds.
MAX_STALE string Indicates that the client is willing to accept responses which have exceeded their freshness lifetime by no more than the specified number of seconds.
MAX_STALE_ANY_AGE int A constant for indicating that the max-stale directive does not specify a limit.
METHOD_NOT_ALLOWED_405 int

The HTTP response status code: 405 Method Not Allowed

MIN_FRESH string Indicates that the client is only accepting responses whose freshness lifetime >= current age + min-fresh
MOVED_PERMANENTLY_301 int

The HTTP response status code: 301 Moved Permanently

MULTIPLE_CHOICES_300 int

The HTTP response status code: 300 Multiple Choices

MUST_REVALIDATE string Indicates that once the response has become stale, it should not be reused for subsequent requests without validating with the origin server.
NON_AUTHORITATIVE_INFORMATION_203 int

The HTTP response status code: 203 Non Authoritative Information

NOT_ACCEPTABLE_406 int

The HTTP response status code: 406 Not Acceptable

NOT_FOUND_404 int

The HTTP response status code: 404 Not Found

NOT_IMPLEMENTED_501 int

The HTTP response status code: 501 Not Implemented

NOT_MODIFIED_304 int

The HTTP response status code: 304 Not Modified

NO_CACHE string Forces the cache to validate a cached response with the origin server before serving.
NO_CONTENT_204 int

The HTTP response status code: 204 No Content

NO_STORE string Instructs the cache to not store a response in non-volatile storage.
NO_TRANSFORM string Instructs intermediaries not to transform the payload.
OK_200 int

The HTTP response status code: 200 OK

ONLY_IF_CACHED string Indicates that the client is only willing to accept a cached response. A cached response is served subject to other constraints posed by the request.
PARTIAL_CONTENT_206 int

The HTTP response status code: 206 Partial Content

PAYLOAD_TOO_LARGE_413 int

The HTTP response status code: 413 Payload Too Large

PAYMENT_REQUIRED_402 int

The HTTP response status code: 402 Payment Required

PERMANENT_REDIRECT_308 int

The HTTP response status code: 308 Permanent Redirect

PRAGMA string

HTTP header key 'pragma'. Used in dealing with HTTP 1.0 caches which do not understand the 'cache-control' header.

PRECONDITION_FAILED_412 int

The HTTP response status code: 412 Precondition Failed

PRIVATE string Indicates that the response is intended for a single user and should not be stored by shared caches.
PROXY_AUTHENTICATION_REQUIRED_407 int

The HTTP response status code: 407 Proxy Authentication Required

PROXY_REVALIDATE string Has the same meaning as must-revalidate, except that this does not apply to private caches.
PUBLIC string Indicates that any cache may store the response.
RANGE_NOT_SATISFIABLE_416 int

The HTTP response status code: 416 Range Not Satisfiable

REDIRECT_FOUND_302 RedirectCode
REDIRECT_MOVED_PERMANENTLY_301 RedirectCode
REDIRECT_MULTIPLE_CHOICES_300 RedirectCode Status codes for HTTP redirect
REDIRECT_NOT_MODIFIED_304 RedirectCode
REDIRECT_PERMANENT_REDIRECT_308 RedirectCode
REDIRECT_SEE_OTHER_303 RedirectCode
REDIRECT_TEMPORARY_REDIRECT_307 RedirectCode
REDIRECT_USE_PROXY_305 RedirectCode
REQUEST_TIMEOUT_408 int

The HTTP response status code: 408 Request Timeout

RESET_CONTENT_205 int

The HTTP response status code: 205 Reset Content

RFC_7234 CachingPolicy
ROUND_ROBIN string Stands for the round robin algorithm for load balancing.
SEE_OTHER_303 int

The HTTP response status code: 303 See Other

SERVICE_UNAVAILABLE_503 int

The HTTP response status code: 503 Service Unavailable

SWITCHING_PROTOCOLS_101 int

The HTTP response status code: 101 Switching Protocols

S_MAX_AGE string In shared caches, this overrides the max-age or Expires header field
TEMPORARY_REDIRECT_307 int

The HTTP response status code: 307 Temporary Redirect

TRANSFERENCODE_CHUNKING TransferEncoding
UNAUTHORIZED_401 int

The HTTP response status code: 401 Unauthorized

UNSUPPORTED_MEDIA_TYPE int

The HTTP response status code: 415 Unsupported Media Type

UPGRADE_REQUIRED_426 int

The HTTP response status code: 426 Upgrade Required

URI_TOO_LONG_414 int

The HTTP response status code: 414 URI Too Long

USE_PROXY_305 int

The HTTP response status code: 305 Use Proxy

WARNING string

HTTP header key 'warning'. Specifies warnings generated when serving stale responses from HTTP caches.

public object AuthConfig

AuthConfig record represents the authentication mechanism that HTTP client uses

Field Name Data Type Default Value Description
scheme string scheme of the configuration. (basic, oauth, jwt etc.)
username string username for basic authentication
password string
accessToken string access token for oauth2 authentication
refreshToken string refresh token for oauth2 authentication
refreshUrl string refresh token url for oauth2 authentication
consumerKey string consume key for oauth2 authentication
consumerSecret string consume secret for oauth2 authentication
tokenUrl string token url for oauth2 authentication
clientId string clietnt id for oauth2 authentication
clientSecret string client secret for oauth2 authentication

public object AuthProvider

Configuration for authentication providers

Field Name Data Type Default Value Description
scheme string Authentication schem
id string Authention provider instance id
authProvider string Authentication schem implementation
issuer string Identifier of the token issuer
audience string Identifier of the token recipients
trustStore TrustStore Trustore configurations
certificateAlias string Token signed key alias
clockSkew int Time in seconds to mitigate clock skew

public object Authentication

Representation of Authentication Config

Field Name Data Type Default Value Description
enabled boolean flag to enable/disable authentication

public object Bucket

Represents Circuit Breaker sub window (Bucket).

Field Name Data Type Default Value Description
successCount int
  • Number of successes during sub window time frame.
failureCount int
  • Number of faiures during sub window time frame.

public object CacheConfig

CacheConfig record is used for providing the caching configurations necessary for the HTTP caching client.

Field Name Data Type Default Value Description
enabled boolean true Specifies whether HTTP caching is enabled. Caching is enabled by default.
isShared boolean false Specifies whether the HTTP caching client should behave as a public cache or a private cache
expiryTimeMillis int 86400 The number of milliseconds to keep an entry in the cache
capacity int 8388608 The capacity of the cache
evictionFactor float 0.2 The fraction of entries to be removed when the cache is full. The value should be between 0 (exclusive) and 1 (inclusive).
policy CachingPolicy CACHE_CONTROL_AND_VALIDATORS Gives the user some control over the caching behaviour. By default, this is set to CACHE_CONTROL_AND_VALIDATORS. The default behaviour is to allow caching only when the Cache-Control header and either the ETag or Last-Modified header are present.

public object CircuitBreakerConfig

Represents Circuit Breaker configuration.

Field Name Data Type Default Value Description
rollingWindow RollingWindow
failureThreshold float
  • The threshold for request failures. When this threshold is crossed, the circuit will trip. The threshold should be a value between 0 and 1.
resetTimeMillis int
  • The time period(in milliseconds) to wait before attempting to make another request to the upstream service.
statusCodes int[]
  • Array of http response status codes which considered as failure responses.

public object CircuitBreakerInferredConfig

Field Name Data Type Default Value Description
failureThreshold float
resetTimeMillis int
statusCodes boolean[]
noOfBuckets int
rollingWindow RollingWindow

public object CircuitHealth

Represents Circuit health of the Circuit Breaker.

Field Name Data Type Default Value Description
startTime Time
  • Circuit Breaker start time. The threshold should be a value between 0 and 1.
requestCount int
  • Total request count from the start.
errorCount int
  • Total error count.
lastErrorTime Time
  • Time that the last error occurred.
totalBuckets Bucket[]
  • Number of buckets fits to the time window.
lastUsedBucketId int
  • Id of the last bucket used in Circuit Breaker calculations.

public object ClientEndpointConfig

ClientEndpointConfig struct represents options to be used for HTTP client invocation

Field Name Data Type Default Value Description
url string Target service URI
circuitBreaker CircuitBreakerConfig Circuit Breaker configuration
timeoutMillis int 60000 Endpoint timeout value in millisecond
keepAlive KeepAlive KEEPALIVE_AUTO Specifies whether to reuse a connection for multiple requests
transferEncoding TransferEncoding CHUNKING The types of encoding applied to the request
chunking Chunking AUTO The chunking behaviour of the request
httpVersion string 1.1 The HTTP version understood by the client
forwarded string disable The choice of setting forwarded/x-forwarded header
followRedirects FollowRedirects Redirect related options
retryConfig RetryConfig Retry related options
proxy ProxyConfig Proxy server related options
connectionThrottling ConnectionThrottling Configurations for connection throttling
secureSocket SecureSocket SSL/TLS related options
cache CacheConfig HTTP caching related configurations
acceptEncoding AcceptEncoding ACCEPT_ENCODING_AUTO Specifies the way of handling accept-encoding header.
auth AuthConfig HTTP authentication releated configurations.

public object ConnectionThrottling

This struct represents the options to be used for connection throttling

Field Name Data Type Default Value Description
maxActiveConnections int -1 Number of maximum active connections for connection throttling. Default value -1, indicates the number of connections are not restricted
waitTime int 60000 Maximum waiting time for a request to grab an idle connection from the client connector
maxActiveStreamsPerConnection int -1 Maximum number of active streams allowed per an HTTP/2 connection

public object CorsConfig

Configurations for CORS support

Field Name Data Type Default Value Description
allowHeaders string[] The array of allowed headers by the service
allowMethods string[] The array of allowed methods by the service
allowOrigins string[] The array of origins with which the response is shared by the service
exposeHeaders string[] The whitelisted headers which clients are allowed to access
allowCredentials boolean Specifies whether credentials are required to access the service
maxAge int -1 The maximum duration to cache the preflight from client side

public object FailoverClientEndpointConfiguration

The configurations related to the failover client endpoint.

Field Name Data Type Default Value Description
circuitBreaker CircuitBreakerConfig
  • Circuit Breaker configuration
timeoutMillis int 60000
  • The maximum time to wait (in milli seconds) for a response before closing the connection
httpVersion string 1.1
  • The HTTP version to be used to communicate with the endpoint
forwarded string disable
  • The choice of setting forwarded/x-forwarded header
keepAlive KeepAlive KEEPALIVE_AUTO
  • Specifies whether to keep the connection alive (or not) for multiple request/response pairs
transferEncoding TransferEncoding CHUNKING
  • The types of encoding applied to the request
chunking Chunking AUTO
  • The chunking behaviour of the request
followRedirects FollowRedirects
  • Redirect related options
retryConfig RetryConfig
  • Retry related options
proxy ProxyConfig
  • Proxy related options
connectionThrottling ConnectionThrottling
  • The configurations for controlling the number of connections allowed concurrently
targets TargetService[]
cache CacheConfig []
  • The configurations for controlling the caching behaviour
acceptEncoding AcceptEncoding ACCEPT_ENCODING_AUTO
  • Specifies the way of handling accept-encoding header
auth AuthConfig
  • HTTP authentication releated configurations
failoverCodes int[] [501, 502, 503, 504]
  • Array of http response status codes which required failover the requests
intervalMillis int
  • Failover delay interval in milliseconds

public object FailoverConfig

Represents Failover connector retry configuration.

Field Name Data Type Default Value Description
failoverCodes int[] Array of http response status codes which required failover the requests.
interval int Failover delay interval in millisecond.

public object FailoverConnectorError

Represents an error occurred in an function of the Failover connector.

Field Name Data Type Default Value Description
message string An error message explaining about the error.
cause error The error that caused HttpConnectorError to get thrown.
statusCode int HTTP status code of the FailoverConnectorError.
httpConnectorError HttpConnectorError[] Array of HttpConnectorError error occurred at each endpoint.

public object FailoverInferredConfig

Field Name Data Type Default Value Description
failoverClientsArray CallerActions[]
failoverCodesIndex boolean[]
failoverInterval int

public object FilterResult

Represents a filter result. This should be populated and returned by each request and response filter function

Field Name Data Type Default Value Description
canProceed boolean Flag to check if the execution of the request should proceed or stopped
statusCode int Status code which will be returned to the request sender if the canProceed is set to false
message string Message which will be returned to the request sender if the canProceed is set to false

public object FollowRedirects

FollowRedirects struct represents HTTP redirect related options to be used for HTTP client invocation

Field Name Data Type Default Value Description
enabled boolean false Enable redirect
maxCount int 5 Maximun number of redirects to follow

public object HttpConnectorError

HttpConnectorError record represents an error occured during the HTTP client invocation

Field Name Data Type Default Value Description
message string An error message explaining the error
cause error The error(s) which caused the HttpConnectorError
statusCode int HTTP status code

public object HttpResourceConfig

Configuration for an HTTP resource

Field Name Data Type Default Value Description
methods string[] The array of allowed HTTP methods
path string The path of resource
body string Inbound request entity body name which declared in signature
consumes string[] The media types which are accepted by resource
produces string[] The media types which are produced by resource
cors CorsConfig The CORS configurations for the resource. If not set, the resource will inherit the CORS behaviour of the enclosing service.
transactionInfectable boolean true
webSocketUpgrade WebSocketUpgradeConfig
authConfig ListenerAuthConfig AuthConfig instance to secure the resource

public object HttpServiceConfig

Configuration for an HTTP service

Field Name Data Type Default Value Description
endpoints Listener[] An array of endpoints the service would be attached to
lifetime HttpServiceLifeTime The life time of the service
basePath string Service base path
compression Compression AUTO The status of compression {default value : AUTO}
chunking Chunking CHUNKING_AUTO
cors CorsConfig The CORS configurations for the service
versioning Versioning
authConfig ListenerAuthConfig AuthConfig instance to secure the service

public object HttpTimeoutError

HttpTimeoutError record represents a timeout error occurred during service invocation.

Field Name Data Type Default Value Description
message string An error message explaining the error
cause error The error(s) which caused the HttpTimeoutError
statusCode int HTTP status code.

public object KeyStore

KeyStore record represents key store related options to be used for HTTP client/service invocation

Field Name Data Type Default Value Description
path string File path to key store file
password string Key store password

public object ListenerAuthConfig

Representation of AuthConfig

Field Name Data Type Default Value Description
authentication Authentication Authentication instance
authProviders string[]
scopes string[] array of scopes

public object LoadBalanceClientEndpointConfiguration

The configurations related to the load balance client endpoint.

Field Name Data Type Default Value Description
circuitBreaker CircuitBreakerConfig
  • Circuit Breaker configuration
timeoutMillis int 60000
  • The maximum time to wait (in milli seconds) for a response before closing the connection
httpVersion string 1.1
  • The HTTP version to be used to communicate with the endpoint
forwarded string disable
  • The choice of setting forwarded/x-forwarded header
keepAlive KeepAlive KEEPALIVE_AUTO
  • Specifies whether to keep the connection alive (or not) for multiple request/response pairs
transferEncoding TransferEncoding CHUNKING
  • The types of encoding applied to the request
chunking Chunking AUTO
  • The chunking behaviour of the request
followRedirects FollowRedirects
  • Redirect related options
retryConfig RetryConfig
  • Retry related options
proxy ProxyConfig
  • Proxy related options
connectionThrottling ConnectionThrottling
  • The configurations for controlling the number of connections allowed concurrently
targets TargetService[]
cache CacheConfig []
  • The configurations for controlling the caching behaviour
acceptEncoding AcceptEncoding ACCEPT_ENCODING_AUTO
  • Specifies the way of handling accept-encoding header
auth AuthConfig
  • HTTP authentication releated configurations
algorithm string ROUND_ROBIN
  • The algorithm to be used for load balancing. The HTTP package provides 'roundRobin()' by default
failover boolean true
  • Configuration for load balancer whether to fail over in case of a failure

public object LoadBalanceConnectorError

Represents an error occurred in an action of the Load Balance connector.

Field Name Data Type Default Value Description
message string An error message explaining about the error.
cause error The error that caused HttpConnectorError to get thrown.
statusCode int HTTP status code of the LoadBalanceConnectorError.
httpConnectorError HttpConnectorError[] Array of HttpConnectorError error occurred at each endpoint.

public object Local

Represents the details of local address.

Field Name Data Type Default Value Description
host string
  • The local server host.
port int
  • The local server port.

public object PayloadError

Represent all http payload related errors

Field Name Data Type Default Value Description
message string The error message
cause error The error which caused the entity error

public object Protocols

Protocols record represents SSL/TLS protocol related options to be used for HTTP client/service invocation

Field Name Data Type Default Value Description
name string SSL Protocol to be used. eg: TLS1.2
versions string[] SSL/TLS protocols to be enabled. eg: TLSv1,TLSv1.1,TLSv1.2

public object ProxyConfig

ProxyConfig struct represents proxy server configurations to be used for HTTP client invocation

Field Name Data Type Default Value Description
host string
port int
userName string
password string

public object Remote

Represents the details of remote address.

Field Name Data Type Default Value Description
host string
  • The remote server host.
port int
  • The remote server port.

public object RequestLimits

Request validation limits configuration for HTTP service endpoint

Field Name Data Type Default Value Description
maxUriLength int -1 Maximum length allowed in the URL
maxHeaderSize int -1 Maximum size allowed in the headers
maxEntityBodySize int -1 Maximum size allowed in the entity body

public object RetryConfig

RetryConfig struct represents retry related options for HTTP client invocation

Field Name Data Type Default Value Description
count int Number of retry attempts before giving up
interval int Retry interval in milliseconds
backOffFactor float Multiplier of the retry interval to exponentailly increase retry interval
maxWaitInterval int Maximum time of the retry interval in milliseconds

public object RollingWindow

Represents Circuit Breaker rolling window configuration.

Field Name Data Type Default Value Description
timeWindowMillis int 60000
  • Time period in milliseconds which the failure threshold is calculated.
bucketSizeMillis int 10000
  • The size of a sub unit in milliseconds that the timeWindow should be divided.

public object SecureEndpointConfiguration

Configuration for secure HTTP service endpoint

Field Name Data Type Default Value Description
host string Host of the service
port int 9090 Port number of the service
keepAlive KeepAlive KEEPALIVE_AUTO The keepAlive behaviour of the connection for a particular port
transferEncoding TransferEncoding TRANSFERENCODE_CHUNKING The types of encoding applied to the response
secureSocket ServiceSecureSocket The SSL configurations for the service endpoint
httpVersion string 1.1 Highest HTTP version supported
requestLimits RequestLimits Request validation limits configuration
filters Filter[] Filters to be applied to the request before dispatched to the actual resource
authProviders AuthProvider[] The array of AuthProviders which are used to authenticate the users

public object SecureSocket

SecureSocket struct represents SSL/TLS options to be used for HTTP client invocation

Field Name Data Type Default Value Description
trustStore TrustStore TrustStore related options
keyStore KeyStore KeyStore related options
protocol Protocols
certValidation ValidateCert Certificate validation against CRL or OCSP related options
ciphers string[] List of ciphers to be used. eg: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
verifyHostname boolean true Enable/disable host name verification
shareSession boolean true Enable/disable new ssl session creation
ocspStapling boolean Enable/disable ocsp stapling

public object ServiceEndpointConfiguration

Configuration for HTTP service endpoint

Field Name Data Type Default Value Description
host string Host of the service
port int 9090 Port number of the service
keepAlive KeepAlive KEEPALIVE_AUTO The keepAlive behaviour of the connection for a particular port
transferEncoding TransferEncoding TRANSFERENCODE_CHUNKING The types of encoding applied to the response
secureSocket ServiceSecureSocket The SSL configurations for the service endpoint
httpVersion string 1.1 Highest HTTP version supported
requestLimits RequestLimits Request validation limits configuration
filters Filter[] Filters to be applied to the request before dispatched to the actual resource

public object ServiceOcspStapling

OcspStapling record represents options related to check whether a certificate is revoked or not

Field Name Data Type Default Value Description
enable boolean The status of OcspStapling
cacheSize int Maximum size of the cache
cacheValidityPeriod int Time duration of cache validity period

public object ServiceSecureSocket

SecureSocket struct represents SSL/TLS options to be used for HTTP service

Field Name Data Type Default Value Description
trustStore TrustStore TrustStore related options
keyStore KeyStore KeyStore related options
protocol Protocols
certValidation ValidateCert Certificate validation against CRL or OCSP related options
ciphers string[] List of ciphers to be used. eg: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
sslVerifyClient string The type of client certificate verification
shareSession boolean true Enable/disable new ssl session creation
ocspStapling ServiceOcspStapling Enable/disable ocsp stapling

public object TargetService

Represents the configurations applied to a particular service.

Field Name Data Type Default Value Description
url string Target service URI
secureSocket SecureSocket SSL/TLS related options

public object TrustStore

TrustStore record represents trust store related options to be used for HTTP client/service invocation

Field Name Data Type Default Value Description
path string File path to trust store file
password string Trust store password

public object ValidateCert

ValidateCert record represents options related to check whether a certificate is revoked or not

Field Name Data Type Default Value Description
enable boolean The status of validateCertEnabled
cacheSize int Maximum size of the cache
cacheValidityPeriod int Time duration of cache validity period

public object Versioning

Configurations for service versioning

Field Name Data Type Default Value Description
pattern string v{major}.{minor} Expecting version pattern in the request url
allowNoVersion boolean false Allow to dispatch requests which does not hold version path segment in url
matchMajorVersion boolean false Allow to dispatch requests which specify only the major version in url

public object WSServiceConfig

Configuration for a WebSocket service.

Field Name Data Type Default Value Description
endpoints Listener[] An array of endpoints the service would be attached to
webSocketEndpoints WebSocketListener[]
path string
subProtocols string[] Negotiable sub protocol by the service
idleTimeoutInSeconds int Idle timeout for the client connection. This can be triggered by putting onIdleTimeout resource in WS service.
maxFrameSize int The maximum payload size of a WebSocket frame in bytes

public object WebSocketClientEndpointConfig

Configuration struct for WebSocket client connection

Field Name Data Type Default Value Description
url string
callbackService typedesc
subProtocols string[] Negotiable sub protocols for the client
customHeaders map<string> Custom headers which should be sent to the server
idleTimeoutInSeconds int -1 Idle timeout of the client. Upon timeout, onIdleTimeout resource in the client service will be triggered (if there is one defined).
readyOnConnect boolean true

public object WebSocketUpgradeConfig

Field Name Data Type Default Value Description
upgradePath string
upgradeService typedesc

public function createHttpCachingClient(string url, ClientEndpointConfig config, CacheConfig cacheConfig) returns (CallerActions)

Creates an HTTP client capable of caching HTTP responses.

Parameter Name Data Type Default Value Description
url string
config ClientEndpointConfig
cacheConfig CacheConfig
Return Type Description
CallerActions

public function createHttpClient(string uri, ClientEndpointConfig config) returns (CallerActions)

Parameter Name Data Type Default Value Description
uri string
config ClientEndpointConfig
Return Type Description
CallerActions

public function createHttpSecureClient(string url, ClientEndpointConfig config) returns (CallerActions)

Creates an HTTP client capable of securing HTTP requests with authentication.

Parameter Name Data Type Default Value Description
url string
config ClientEndpointConfig
Return Type Description
CallerActions

public function createSimpleHttpClient(string uri, ClientEndpointConfig config) returns (CallerActions)

Parameter Name Data Type Default Value Description
uri string
config ClientEndpointConfig
Return Type Description
CallerActions

public function decode(string url, string charset) returns (string | error)

Decodes the given URL

Parameter Name Data Type Default Value Description
url string URL to be decoded
charset string Charactor set that URL to be decoded
Return Type Description
string | error The decoded URL

public function encode(string url, string charset) returns (string | error)

Encodes the given URL

Parameter Name Data Type Default Value Description
url string URL to be encoded
charset string Charactor set that URL to be encoded
Return Type Description
string | error The encoded URL

public function extractBasicAuthHeaderValue(Request req) returns (string | null)

Extracts the basic authentication header value from the request

Parameter Name Data Type Default Value Description
req Request Request instance
Return Type Description
string | null string: value of the basic authentication header, or null if not found

public function getcurrentFailureRatio(CircuitHealth circuitHealth) returns (float)

Calculate Failure at a given point.

Parameter Name Data Type Default Value Description
circuitHealth CircuitHealth
  • Circuit Breaker health status.
Return Type Description
float

public function invokeEndpoint(string path, Request outRequest, HttpOperation requestAction, CallerActions httpClient) returns (Response | HttpConnectorError)

Parameter Name Data Type Default Value Description
path string
outRequest Request
requestAction HttpOperation
httpClient CallerActions
Return Type Description
Response | HttpConnectorError

public function parseHeader(string headerValue) returns ((string,map) | error)

Parse headerValue and return value with parameter map

Parameter Name Data Type Default Value Description
headerValue string The header value
Return Type Description
(string,map) | error The header value

public function resetBucketStats(CircuitHealth circuitHealth, int bucketId)

Reset the bucket values to default ones.

Parameter Name Data Type Default Value Description
circuitHealth CircuitHealth
  • Circuit Breaker health status.
bucketId int
  • Id of the bucket should reset.

public function roundRobin(LoadBalancer lb, CallerActions[] loadBalanceConfigArray) returns (CallerActions)

Parameter Name Data Type Default Value Description
lb LoadBalancer
loadBalanceConfigArray CallerActions[]
Return Type Description
CallerActions

public function updateCircuitState(CircuitHealth circuitHealth, CircuitState currentStateValue, CircuitBreakerInferredConfig circuitBreakerInferredConfig) returns (CircuitState)

Parameter Name Data Type Default Value Description
circuitHealth CircuitHealth
currentStateValue CircuitState
circuitBreakerInferredConfig CircuitBreakerInferredConfig
Return Type Description
CircuitState

public type APIListener object

Representation of an API Listener

Field Name Data Type Default Value Description
config SecureEndpointConfiguration SecureEndpointConfiguration instance
secureListener SecureListener Secure HTTP Listener instance
  • <APIListener> init(SecureEndpointConfiguration config)

    Parameter Name Data Type Default Value Description
    config SecureEndpointConfiguration
  • <APIListener> register(typedesc serviceType)

    Parameter Name Data Type Default Value Description
    serviceType typedesc
  • <APIListener> start()

  • <APIListener> getCallerActions() returns (Connection)

    Return Type Description
    Connection
  • <APIListener> stop()

public type AuthHandlerRegistry object

Representation of the Http Auth Handler Registry

  • <AuthHandlerRegistry> add(string id, HttpAuthnHandler authnHandler)

    Parameter Name Data Type Default Value Description
    id string
    authnHandler HttpAuthnHandler
  • <AuthHandlerRegistry> get(string id) returns (HttpAuthnHandler)

    Parameter Name Data Type Default Value Description
    id string
    Return Type Description
    HttpAuthnHandler
  • <AuthHandlerRegistry> getAll() returns (map<HttpAuthnHandler>)

    Return Type Description
    map<HttpAuthnHandler>
  • <AuthHandlerRegistry> remove(string id)

    Parameter Name Data Type Default Value Description
    id string
  • <AuthHandlerRegistry> clear()

public type AuthnFilter object

Representation of the Authentication filter

Field Name Data Type Default Value Description
authnHandlerChain AuthnHandlerChain
  • <AuthnFilter> filterRequest(Request request, FilterContext context) returns (FilterResult)

    filterRequest: Request filter function

    Parameter Name Data Type Default Value Description
    request Request
    context FilterContext
    Return Type Description
    FilterResult

public type AuthnHandlerChain object

Representation of Authentication handler chain

  • <AuthnHandlerChain> handle(Request req) returns (boolean)

    Parameter Name Data Type Default Value Description
    req Request
    Return Type Description
    boolean
  • <AuthnHandlerChain> handleWithSpecificAuthnHandlers(string[] authProviderIds, Request req) returns (boolean)

    Parameter Name Data Type Default Value Description
    authProviderIds string[]
    req Request
    Return Type Description
    boolean

public type AuthzFilter object

Representation of the Authorization filter

Field Name Data Type Default Value Description
authzHandler HttpAuthzHandler
  • <AuthzFilter> filterRequest(Request request, FilterContext context) returns (FilterResult)

    Filter function implementation which tries to authorize the request

    Parameter Name Data Type Default Value Description
    request Request Request instance
    context FilterContext FilterContext instance
    Return Type Description
    FilterResult FilterResult: Authorization result to indicate if the request can proceed or not

public type CallerActions object

The Caller actions for interacting with an HTTP server.

Field Name Data Type Default Value Description
serviceUri string
config ClientEndpointConfig
  • <CallerActions> post(string path) returns (Response | HttpConnectorError)

    The POST action implementation of the HTTP Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> head(string path) returns (Response | HttpConnectorError)

    The HEAD action implementation of the HTTP Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> put(string path) returns (Response | HttpConnectorError)

    The PUT action implementation of the HTTP Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> execute(string httpVerb, string path, Request request) returns (Response | HttpConnectorError)

    Invokes an HTTP call with the specified HTTP verb.

    Parameter Name Data Type Default Value Description
    httpVerb string HTTP verb value
    path string Resource path
    request Request
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> patch(string path) returns (Response | HttpConnectorError)

    The PATCH action implementation of the HTTP Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> delete(string path) returns (Response | HttpConnectorError)

    The DELETE action implementation of the HTTP connector

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> get(string path) returns (Response | HttpConnectorError)

    GET action implementation of the HTTP Connector

    Parameter Name Data Type Default Value Description
    path string Request path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> options(string path) returns (Response | HttpConnectorError)

    OPTIONS action implementation of the HTTP Connector

    Parameter Name Data Type Default Value Description
    path string Request path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> forward(string path, Request request) returns (Response | HttpConnectorError)

    Forward action can be used to invoke an HTTP call with inbound request's HTTP verb

    Parameter Name Data Type Default Value Description
    path string Request path
    request Request
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <CallerActions> submit(string httpVerb, string path, Request request) returns (HttpFuture | HttpConnectorError)

    Submits an HTTP request to a service with the specified HTTP verb.

    Parameter Name Data Type Default Value Description
    httpVerb string The HTTP verb value
    path string The Resource path
    request Request
    Return Type Description
    HttpFuture | HttpConnectorError The Future for further interactions
  • <CallerActions> getResponse(HttpFuture httpFuture) returns (Response | HttpConnectorError)

    Retrieves response for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    Response | HttpConnectorError The HTTP response message
  • <CallerActions> hasPromise(HttpFuture httpFuture) returns (boolean)

    Checks whether server push exists for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    boolean Whether push promise exists
  • <CallerActions> getNextPromise(HttpFuture httpFuture) returns (PushPromise | HttpConnectorError)

    Retrieves the next available push promise for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    PushPromise | HttpConnectorError The HTTP Push Promise message
  • <CallerActions> getPromisedResponse(PushPromise promise) returns (Response | HttpConnectorError)

    Retrieves the promised server push response.

    Parameter Name Data Type Default Value Description
    promise PushPromise The related Push Promise message
    Return Type Description
    Response | HttpConnectorError HTTP The Push Response message
  • <CallerActions> rejectPromise(PushPromise promise)

    Rejects a push promise.

    Parameter Name Data Type Default Value Description
    promise PushPromise The Push Promise need to be rejected

public type CircuitBreakerClient object

Represents an HTTP Circuit Breaker client to be used with the HTTP client connector to gracefully handle network errors.

Field Name Data Type Default Value Description
serviceUri string
  • Target service url.
config ClientEndpointConfig
  • Circuit Breaker configuration.
circuitBreakerInferredConfig CircuitBreakerInferredConfig
  • Dirived configuration from circuit Breaker configuration.
httpClient CallerActions
  • HTTP client for outbound HTTP requests.
circuitHealth CircuitHealth
  • Struct which maintain the circuit status.
currentCircuitState CircuitState CB_CLOSED_STATE
  • Current state of the circuit.
  • <CircuitBreakerClient> post(string path) returns (Response | HttpConnectorError)

    The POST action implementation of the Circuit Breaker. Protects the invocation of the POST action of the underlying HTTP client connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> head(string path) returns (Response | HttpConnectorError)

    The HEAD action implementation of the Circuit Breaker. Protects the invocation of the HEAD action of the underlying HTTP client connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> put(string path) returns (Response | HttpConnectorError)

    The PUT action implementation of the Circuit Breaker. Protects the invocation of the PUT action of the underlying HTTP client connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> execute(string httpVerb, string path, Request request) returns (Response | HttpConnectorError)

    Protects the invocation of the Execute action of the underlying HTTP client connector. The Execute action can be used to invoke an HTTP call with the given HTTP verb.

    Parameter Name Data Type Default Value Description
    httpVerb string HTTP verb to be used for the request
    path string Resource path
    request Request A Request struct
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> patch(string path) returns (Response | HttpConnectorError)

    The PATCH action implementation of the Circuit Breaker. Protects the invocation of the PATCH action of the underlying HTTP client connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> delete(string path) returns (Response | HttpConnectorError)

    The DELETE action implementation of the Circuit Breaker. Protects the invocation of the DELETE action of the underlying HTTP client connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> get(string path) returns (Response | HttpConnectorError)

    The GET action implementation of the Circuit Breaker. Protects the invocation of the GET action of the underlying HTTP client connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> options(string path) returns (Response | HttpConnectorError)

    The OPTIONS action implementation of the Circuit Breaker. Protects the invocation of the OPTIONS action of the underlying HTTP client connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> forward(string path, Request request) returns (Response | HttpConnectorError)

    Protects the invocation of the Forward action of the underlying HTTP client connector. The Forward action can be used to forward an incoming request to an upstream service as it is.

    Parameter Name Data Type Default Value Description
    path string Resource path
    request Request A Request struct
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <CircuitBreakerClient> submit(string httpVerb, string path, Request request) returns (HttpFuture | HttpConnectorError)

    The submit implementation of Circuit Breaker.

    Parameter Name Data Type Default Value Description
    httpVerb string The HTTP verb value
    path string The Resource path
    request Request
    Return Type Description
    HttpFuture | HttpConnectorError The Future for further interactions
  • <CircuitBreakerClient> getResponse(HttpFuture httpFuture) returns (Response | HttpConnectorError)

    The getResponse implementation of Circuit Breaker.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    Response | HttpConnectorError The HTTP response message
  • <CircuitBreakerClient> hasPromise(HttpFuture httpFuture) returns (boolean)

    The hasPromise implementation of Circuit Breaker.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    boolean Whether push promise exists
  • <CircuitBreakerClient> getNextPromise(HttpFuture httpFuture) returns (PushPromise | HttpConnectorError)

    The getNextPromise implementation of Circuit Breaker.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    PushPromise | HttpConnectorError The HTTP Push Promise message
  • <CircuitBreakerClient> getPromisedResponse(PushPromise promise) returns (Response | HttpConnectorError)

    The getPromisedResponse implementation of Circuit Breaker.

    Parameter Name Data Type Default Value Description
    promise PushPromise The related Push Promise message
    Return Type Description
    Response | HttpConnectorError HTTP The Push Response message
  • <CircuitBreakerClient> rejectPromise(PushPromise promise)

    The rejectPromise implementation of Circuit Breaker.

    Parameter Name Data Type Default Value Description
    promise PushPromise The Push Promise need to be rejected

public type Client object

Represents an HTTP client endpoint

Field Name Data Type Default Value Description
epName string The name of the endpoint
config ClientEndpointConfig The configurations associated with the endpoint
httpClient CallerActions
  • <Client> init(ClientEndpointConfig config)

    Gets called when the endpoint is being initialized during the package initialization.

    Parameter Name Data Type Default Value Description
    config ClientEndpointConfig The ClientEndpointConfig of the endpoint
  • <Client> register(typedesc serviceType)

    Parameter Name Data Type Default Value Description
    serviceType typedesc
  • <Client> start()

  • <Client> getCallerActions() returns (CallerActions)

    Returns the connector that client code uses

    Return Type Description
    CallerActions The connector that client code uses
  • <Client> stop()

    Stops the registered service

public type Connection object

Represents HTTP connection which can be used to comminicate either with client or with other service.

  • <Connection> respond(Response res) returns (HttpConnectorError | null)

    Sends outbound response to the caller

    Parameter Name Data Type Default Value Description
    res Response The outbound response message
    Return Type Description
    HttpConnectorError | null Error occured during HTTP server connector respond
  • <Connection> promise(PushPromise promise) returns (HttpConnectorError | null)

    Pushes a promise to the caller.

    Parameter Name Data Type Default Value Description
    promise PushPromise Push promise message
    Return Type Description
    HttpConnectorError | null Error occured during HTTP server connector promise function invocation
  • <Connection> pushPromisedResponse(PushPromise promise, Response res) returns (HttpConnectorError | null)

    Sends a promised push response to the caller.

    Parameter Name Data Type Default Value Description
    promise PushPromise Push promise message
    res Response The outbound response message
    Return Type Description
    HttpConnectorError | null Error occured during HTTP server connector pushPromisedResponse function invocation
  • <Connection> acceptWebSocketUpgrade(map headers) returns (WebSocketListener)

    Sends a upgrade request with custom headers

    Parameter Name Data Type Default Value Description
    headers map a map of custom headers for handshake.
    Return Type Description
    WebSocketListener
  • <Connection> cancelWebSocketUpgrade(int status, string reason)

    Cancels the handshake

    Parameter Name Data Type Default Value Description
    status int
    reason string Reason for closing the connection
  • <Connection> continue() returns (HttpConnectorError | null)

    Return Type Description
    HttpConnectorError | null
  • <Connection> redirect(Response response, RedirectCode code, string[] locations) returns (HttpConnectorError | null)

    Parameter Name Data Type Default Value Description
    response Response
    code RedirectCode
    locations string[]
    Return Type Description
    HttpConnectorError | null

public type Failover object

Failover client implementation to be used with the HTTP client connector to support failover.

Field Name Data Type Default Value Description
serviceUri string Service path.
config ClientEndpointConfig Represents options to be used for HTTP client invocation.
failoverInferredConfig FailoverInferredConfig Represents inferred failover configurations passed to Failover connector.
  • <Failover> post(string path) returns (Response | HttpConnectorError)

    The POST function implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> head(string path) returns (Response | HttpConnectorError)

    The HEAD function implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> patch(string path) returns (Response | HttpConnectorError)

    The PATCH function implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> put(string path) returns (Response | HttpConnectorError)

    The PUT function implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> options(string path) returns (Response | HttpConnectorError)

    The OPTIONS function implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> forward(string path, Request request) returns (Response | HttpConnectorError)

    The FORWARD function implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    request Request A Request struct
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> execute(string httpVerb, string path, Request request) returns (Response | HttpConnectorError)

    The EXECUTE function implementation of the Failover Connector. The Execute function can be used to invoke an HTTP call with the given HTTP verb.

    Parameter Name Data Type Default Value Description
    httpVerb string HTTP verb to be used for the request
    path string Resource path
    request Request A Request struct
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> delete(string path) returns (Response | HttpConnectorError)

    The DELETE function implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> get(string path) returns (Response | HttpConnectorError)

    The GET function implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <Failover> submit(string httpVerb, string path, Request request) returns (HttpFuture | HttpConnectorError)

    The submit implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    httpVerb string The HTTP verb value
    path string The Resource path
    request Request
    Return Type Description
    HttpFuture | HttpConnectorError The Future for further interactions
  • <Failover> getResponse(HttpFuture httpFuture) returns (HttpConnectorError)

    The getResponse implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    HttpConnectorError The HTTP response message
  • <Failover> hasPromise(HttpFuture httpFuture) returns (boolean)

    The hasPromise implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    boolean Whether push promise exists
  • <Failover> getNextPromise(HttpFuture httpFuture) returns (PushPromise | HttpConnectorError)

    The getNextPromise implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    PushPromise | HttpConnectorError The HTTP Push Promise message
  • <Failover> getPromisedResponse(PushPromise promise) returns (Response | HttpConnectorError)

    The getPromisedResponse implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    promise PushPromise The related Push Promise message
    Return Type Description
    Response | HttpConnectorError HTTP The Push Response message
  • <Failover> rejectPromise(PushPromise promise)

    The rejectPromise implementation of the Failover Connector.

    Parameter Name Data Type Default Value Description
    promise PushPromise The Push Promise need to be rejected

public type FailoverClient object

FailoverClient endpoint provides failover support over multiple HTTP clients.

Field Name Data Type Default Value Description
epName string
  • Name of the endpoint
failoverClientConfig FailoverClientEndpointConfiguration
  • The configurations for the failover client endpoint
  • <FailoverClient> init(FailoverClientEndpointConfiguration failoverClientConfig)

    Parameter Name Data Type Default Value Description
    failoverClientConfig FailoverClientEndpointConfiguration
  • <FailoverClient> register(typedesc serviceType)

        The register() function is not implemented for the failover client endpoint.
    

    Parameter Name Data Type Default Value Description
    serviceType typedesc
  • <FailoverClient> start()

        The start() function is not implemented for the failover client endpoint.
    

  • <FailoverClient> getCallerActions() returns (CallerActions)

        Returns the backing HTTP client used by the endpoint.
    

    Return Type Description
    CallerActions
  • <FailoverClient> stop()

        The stop() function is not implemented for the failover client endpoint.
    

public type Filter object

Representation of a HTTP Request Filter. This filter will be applied before the request is dispatched to the relevant resource. Any Filter implementation should be struct-wise similar to the Filter struct.

  • <Filter> filterRequest(Request request, FilterContext context) returns (FilterResult)

    filterRequest: Request filter function

    Parameter Name Data Type Default Value Description
    request Request
    context FilterContext
    Return Type Description
    FilterResult

public type FilterContext object

Representation of filter Context.

Field Name Data Type Default Value Description
serviceType typedesc Type of the service
serviceName string Name of the service
resourceName string

public type HttpAuthnHandler object

Representation of Authentication handler for HTTP traffic. Any authention interceptor for basic authentication should be struct-wise similar to HttpAuthnInterceptor

Field Name Data Type Default Value Description
name string
  • <HttpAuthnHandler> canHandle(Request req) returns (boolean)

    Parameter Name Data Type Default Value Description
    req Request
    Return Type Description
    boolean
  • <HttpAuthnHandler> handle(Request req) returns (boolean)

    Parameter Name Data Type Default Value Description
    req Request
    Return Type Description
    boolean

public type HttpBasicAuthnHandler object

Representation of Basic Auth handler for HTTP traffic

Field Name Data Type Default Value Description
name string Authentication handler name
authProvider AuthProvider AuthProvider instance
  • <HttpBasicAuthnHandler> canHandle(Request req) returns (boolean)

    Parameter Name Data Type Default Value Description
    req Request
    Return Type Description
    boolean
  • <HttpBasicAuthnHandler> handle(Request req) returns (boolean)

    Parameter Name Data Type Default Value Description
    req Request
    Return Type Description
    boolean

public type HttpCachingClient object

An HTTP caching client implementation which takes an HttpClient and wraps it with a caching layer.

Field Name Data Type Default Value Description
serviceUri string
config ClientEndpointConfig
httpClient CallerActions The underlying HTTP client which will be making the actual network calls
cache HttpCache
cacheConfig CacheConfig Caching configurations for the HTTP cache
  • <HttpCachingClient> post(string path) returns (Response | HttpConnectorError)

    Responses returned for POST requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for POST requests invalidate the cached responses for the same resource.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> head(string path) returns (Response | HttpConnectorError)

    Responses for HEAD requests are cacheable and as such, will be routed through the HTTP cache. Only if a suitable response cannot be found will the request be directed to the origin server.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> put(string path) returns (Response | HttpConnectorError)

    Responses returned for PUT requests are not cacheable. Therefore, the requests are simply directed to the origin server. In addition, PUT requests invalidate the currently stored responses for the given path.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> execute(string httpMethod, string path, Request request) returns (Response | HttpConnectorError)

    Invokes an HTTP call with the specified HTTP method. This is not a cacheable operation, unless the HTTP method used is GET or HEAD.

    Parameter Name Data Type Default Value Description
    httpMethod string HTTP method to be used for the request
    path string Resource path
    request Request
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> patch(string path) returns (Response | HttpConnectorError)

    Responses returned for PATCH requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for PATCH requests invalidate the cached responses for the same resource.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> delete(string path) returns (Response | HttpConnectorError)

    Responses returned for DELETE requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for DELETE requests invalidate the cached responses for the same resource.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> get(string path) returns (Response | HttpConnectorError)

    Responses for GET requests are cacheable and as such, will be routed through the HTTP cache. Only if a suitable response cannot be found will the request be directed to the origin server.

    Parameter Name Data Type Default Value Description
    path string Request path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> options(string path) returns (Response | HttpConnectorError)

    Responses returned for OPTIONS requests are not cacheable. Therefore, the requests are simply directed to the origin server. Responses received for OPTIONS requests invalidate the cached responses for the same resource.

    Parameter Name Data Type Default Value Description
    path string Request path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> forward(string path, Request request) returns (Response | HttpConnectorError)

    Forward action can be used to invoke an HTTP call with inbound request's HTTP method. Only inbound requests of GET and HEAD HTTP method types are cacheable.

    Parameter Name Data Type Default Value Description
    path string Request path
    request Request
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpCachingClient> submit(string httpVerb, string path, Request request) returns (HttpFuture | HttpConnectorError)

    Submits an HTTP request to a service with the specified HTTP verb.

    Parameter Name Data Type Default Value Description
    httpVerb string The HTTP verb value
    path string The Resource path
    request Request
    Return Type Description
    HttpFuture | HttpConnectorError The Future for further interactions
  • <HttpCachingClient> getResponse(HttpFuture httpFuture) returns (Response | HttpConnectorError)

    Retrieves response for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    Response | HttpConnectorError The HTTP response message
  • <HttpCachingClient> hasPromise(HttpFuture httpFuture) returns (boolean)

    Checks whether server push exists for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    boolean Whether push promise exists
  • <HttpCachingClient> getNextPromise(HttpFuture httpFuture) returns (PushPromise | HttpConnectorError)

    Retrieves the next available push promise for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    PushPromise | HttpConnectorError The HTTP Push Promise message
  • <HttpCachingClient> getPromisedResponse(PushPromise promise) returns (Response | HttpConnectorError)

    Retrieves the promised server push response.

    Parameter Name Data Type Default Value Description
    promise PushPromise The related Push Promise message
    Return Type Description
    Response | HttpConnectorError HTTP The Push Response message
  • <HttpCachingClient> rejectPromise(PushPromise promise)

    Rejects a push promise.

    Parameter Name Data Type Default Value Description
    promise PushPromise The Push Promise need to be rejected

public type HttpFuture object

Represents a future for aynchronous http invocation

public type HttpJwtAuthnHandler object

Representation of JWT Auth handler for HTTP traffic

Field Name Data Type Default Value Description
name string Authentication handler name
jwtAuthenticator JWTAuthProvider JWTAuthenticator instance
  • <HttpJwtAuthnHandler> canHandle(Request req) returns (boolean)

    Parameter Name Data Type Default Value Description
    req Request
    Return Type Description
    boolean
  • <HttpJwtAuthnHandler> handle(Request req) returns (boolean)

    Parameter Name Data Type Default Value Description
    req Request
    Return Type Description
    boolean

public type HttpSecureClient object

An HTTP secure client for interacting with an HTTP server with authentication.

Field Name Data Type Default Value Description
serviceUri string
config ClientEndpointConfig
httpClient CallerActions
  • <HttpSecureClient> post(string path) returns (Response | HttpConnectorError)

    The POST action implementation of the HTTP Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> head(string path) returns (Response | HttpConnectorError)

    The HEAD action implementation of the HTTP Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> put(string path) returns (Response | HttpConnectorError)

    The PUT action implementation of the HTTP Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> execute(string httpVerb, string path, Request request) returns (Response | HttpConnectorError)

    Invokes an HTTP call with the specified HTTP verb.

    Parameter Name Data Type Default Value Description
    httpVerb string HTTP verb value
    path string Resource path
    request Request
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> patch(string path) returns (Response | HttpConnectorError)

    The PATCH action implementation of the HTTP Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> delete(string path) returns (Response | HttpConnectorError)

    The DELETE action implementation of the HTTP connector

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> get(string path) returns (Response | HttpConnectorError)

    GET action implementation of the HTTP Connector

    Parameter Name Data Type Default Value Description
    path string Request path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> options(string path) returns (Response | HttpConnectorError)

    OPTIONS action implementation of the HTTP Connector

    Parameter Name Data Type Default Value Description
    path string Request path
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> forward(string path, Request request) returns (Response | HttpConnectorError)

    Forward action can be used to invoke an HTTP call with inbound request's HTTP verb

    Parameter Name Data Type Default Value Description
    path string Request path
    request Request
    Return Type Description
    Response | HttpConnectorError The inbound response message
  • <HttpSecureClient> submit(string httpVerb, string path, Request request) returns (HttpFuture | HttpConnectorError)

    Submits an HTTP request to a service with the specified HTTP verb.

    Parameter Name Data Type Default Value Description
    httpVerb string The HTTP verb value
    path string The Resource path
    request Request
    Return Type Description
    HttpFuture | HttpConnectorError The Future for further interactions
  • <HttpSecureClient> getResponse(HttpFuture httpFuture) returns (Response | HttpConnectorError)

    Retrieves response for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    Response | HttpConnectorError The HTTP response message
  • <HttpSecureClient> hasPromise(HttpFuture httpFuture) returns (boolean)

    Checks whether server push exists for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    boolean Whether push promise exists
  • <HttpSecureClient> getNextPromise(HttpFuture httpFuture) returns (PushPromise | HttpConnectorError)

    Retrieves the next available push promise for a previously submitted request.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    PushPromise | HttpConnectorError The HTTP Push Promise message
  • <HttpSecureClient> getPromisedResponse(PushPromise promise) returns (Response | HttpConnectorError)

    Retrieves the promised server push response.

    Parameter Name Data Type Default Value Description
    promise PushPromise The related Push Promise message
    Return Type Description
    Response | HttpConnectorError HTTP The Push Response message
  • <HttpSecureClient> rejectPromise(PushPromise promise)

    Rejects a push promise.

    Parameter Name Data Type Default Value Description
    promise PushPromise The Push Promise need to be rejected

public type Listener object

Represents service endpoint where one or more services can be registered. so that ballerina program can offer service through this endpoint.

Field Name Data Type Default Value Description
remote Remote
  • The details of remote address.
local Local
  • The details of local address.
protocol string
  • The protocol associate with the service endpoint.
  • <Listener> init(ServiceEndpointConfiguration config)

    Parameter Name Data Type Default Value Description
    config ServiceEndpointConfiguration
  • <Listener> initEndpoint() returns (error)

    Gets called when the endpoint is being initialize during package init time

    Return Type Description
    error Error occured during initialization
  • <Listener> register(typedesc serviceType)

    Gets called every time a service attaches itself to this endpoint. Also happens at package initialization.

    Parameter Name Data Type Default Value Description
    serviceType typedesc The type of the service to be registered
  • <Listener> start()

    Starts the registered service

  • <Listener> getCallerActions() returns (Connection)

    Returns the connector that client code uses

    Return Type Description
    Connection The connector that client code uses
  • <Listener> stop()

    Stops the registered service

public type LoadBalanceClient object

LoadBalanceClient endpoint provides load balancing functionality over multiple HTTP clients.

Field Name Data Type Default Value Description
epName string
  • Name of the endpoint
loadBalanceClientConfig LoadBalanceClientEndpointConfiguration
  • The configurations for the load balance client endpoint
  • <LoadBalanceClient> init(LoadBalanceClientEndpointConfiguration loadBalanceClientConfig)

    Parameter Name Data Type Default Value Description
    loadBalanceClientConfig LoadBalanceClientEndpointConfiguration
  • <LoadBalanceClient> register(typedesc serviceType)

        The register() function is not implemented for the load balance client endpoint.
    

    Parameter Name Data Type Default Value Description
    serviceType typedesc
  • <LoadBalanceClient> start()

        The start() function is not implemented for the load balance client endpoint.
    

  • <LoadBalanceClient> getCallerActions() returns (CallerActions)

        Returns the backing HTTP client used by the load balance client endpoint.
    

    Return Type Description
    CallerActions
  • <LoadBalanceClient> stop()

        The stop() function is not implemented for the load balance client endpoint.
    

public type LoadBalancer object

Load Balancer adds an additional layer to the HTTP client to make network interactions more resilient.

Field Name Data Type Default Value Description
serviceUri string
config ClientEndpointConfig
loadBalanceClientsArray CallerActions[]
algorithm string
nextIndex int
failover boolean
  • <LoadBalancer> post(string path) returns (Response | HttpConnectorError)

    The POST action implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> head(string path) returns (Response | HttpConnectorError)

    The HEAD action implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> patch(string path) returns (Response | HttpConnectorError)

    The PATCH action implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> put(string path) returns (Response | HttpConnectorError)

    The PUT action implementation of the Load Balance Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> options(string path) returns (Response | HttpConnectorError)

    The OPTIONS action implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> forward(string path, Request request) returns (Response | HttpConnectorError)

    The FORWARD action implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    request Request A Request struct
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> execute(string httpVerb, string path, Request request) returns (Response | HttpConnectorError)

    The EXECUTE action implementation of the LoadBalancer Connector. The Execute action can be used to invoke an HTTP call with the given HTTP verb.

    Parameter Name Data Type Default Value Description
    httpVerb string HTTP verb to be used for the request
    path string Resource path
    request Request A Request struct
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> delete(string path) returns (Response | HttpConnectorError)

    The DELETE action implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> get(string path) returns (Response | HttpConnectorError)

    The GET action implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    path string Resource path
    Return Type Description
    Response | HttpConnectorError The Response struct
  • <LoadBalancer> submit(string httpVerb, string path, Request request) returns (HttpFuture | HttpConnectorError)

    The submit implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    httpVerb string The HTTP verb value
    path string The Resource path
    request Request
    Return Type Description
    HttpFuture | HttpConnectorError The Future for further interactions
  • <LoadBalancer> getResponse(HttpFuture httpFuture) returns (Response | HttpConnectorError)

    The getResponse implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    Response | HttpConnectorError The HTTP response message
  • <LoadBalancer> hasPromise(HttpFuture httpFuture) returns (boolean)

    The hasPromise implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    boolean Whether push promise exists
  • <LoadBalancer> getNextPromise(HttpFuture httpFuture) returns (PushPromise | HttpConnectorError)

    The getNextPromise implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture The Future which relates to previous async invocation
    Return Type Description
    PushPromise | HttpConnectorError The HTTP Push Promise message
  • <LoadBalancer> getPromisedResponse(PushPromise promise) returns (Response | HttpConnectorError)

    The getPromisedResponse implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    promise PushPromise The related Push Promise message
    Return Type Description
    Response | HttpConnectorError HTTP The Push Response message
  • <LoadBalancer> rejectPromise(PushPromise promise)

    The rejectPromise implementation of the LoadBalancer Connector.

    Parameter Name Data Type Default Value Description
    promise PushPromise The Push Promise need to be rejected

public type NonListener object

Mock service endpoint which does not open a listening port.

  • <NonListener> init(ServiceEndpointConfiguration config)

    Parameter Name Data Type Default Value Description
    config ServiceEndpointConfiguration
  • <NonListener> initEndpoint() returns (error)

    Return Type Description
    error
  • <NonListener> register(typedesc serviceType)

    Parameter Name Data Type Default Value Description
    serviceType typedesc
  • <NonListener> start()

  • <NonListener> getCallerActions() returns (Connection)

    Return Type Description
    Connection
  • <NonListener> stop()

public type PushPromise object

Represents a HTTP/2 Push Promise

Field Name Data Type Default Value Description
path string Resource path
method string Http method
  • <PushPromise> hasHeader(string headerName) returns (boolean)

    Checks whether the requested header exists

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    boolean A boolean representing the existence of a given header
  • <PushPromise> getHeader(string headerName) returns (string)

    Returns the header value with the specified header name. If there are more than one header value for the specified header name, the first value is returned.

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    string The first header value for the provided header name. Returns null if the header does not exist.
  • <PushPromise> getHeaders(string headerName) returns (string[])

    Gets transport headers from the Push Promise

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    string[] The header values struct array for a given header name
  • <PushPromise> addHeader(string headerName, string headerValue)

    Adds the specified key/value pair as an HTTP header to the Push Promise

    Parameter Name Data Type Default Value Description
    headerName string The header name
    headerValue string The header value
  • <PushPromise> setHeader(string headerName, string headerValue)

    Sets the value of a transport header in Push Promise

    Parameter Name Data Type Default Value Description
    headerName string The header name
    headerValue string The header value
  • <PushPromise> removeHeader(string key)

    Removes a transport header from the Push Promise

    Parameter Name Data Type Default Value Description
    key string The header name
  • <PushPromise> removeAllHeaders()

    Removes all transport headers from the Push Promise

  • <PushPromise> getHeaderNames() returns (string[])

    Gets all transport header names from the Push Promise.

    Return Type Description
    string[] An array of all transport header names

public type Request object

Represents an HTTP request message

Field Name Data Type Default Value Description
rawPath string
method string HTTP request method
httpVersion string The version of HTTP
userAgent string User-Agent request header
extraPathInfo string Additional information associated with the URL sent by the client
cacheControl RequestCacheControl
  • <Request> setEntity(Entity entity)

    Set the entity to request

    Parameter Name Data Type Default Value Description
    entity Entity
  • <Request> getQueryParams() returns (map<string>)

    Gets the query parameters from the HTTP request as a map

    Return Type Description
    map<string> String map of query params
  • <Request> getMatrixParams(string path) returns (map)

    Get matrix parameters from the request

    Parameter Name Data Type Default Value Description
    path string Path to the location of matrix parameters
    Return Type Description
    map A map of matrix paramters which can be found for a given path
  • <Request> getEntity() returns (mimeEntity | mimeEntityError)

    Get the entity from the request

    Return Type Description
    mimeEntity | mimeEntityError Entity of the request
  • <Request> hasHeader(string headerName) returns (boolean)

    Check whether the requested header exists

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    boolean Boolean representing the existence of a given header
  • <Request> getHeader(string headerName) returns (string)

    Returns the header value with the specified header name. If there are more than one header value for the specified header name, the first value is returned.

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    string The first header value for the provided header name. Returns null if the header does not exist.
  • <Request> getHeaders(string headerName) returns (string[])

    Gets transport headers from the request

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    string[] The header values struct array for a given header name
  • <Request> setHeader(string headerName, string headerValue)

    Sets the value of a transport header

    Parameter Name Data Type Default Value Description
    headerName string The header name
    headerValue string The header value
  • <Request> addHeader(string headerName, string headerValue)

    Adds the specified key/value pair as an HTTP header to the request

    Parameter Name Data Type Default Value Description
    headerName string The header name
    headerValue string The header value
  • <Request> removeHeader(string key)

    Removes a transport header from the request

    Parameter Name Data Type Default Value Description
    key string The header name
  • <Request> removeAllHeaders()

    Removes all transport headers from the message

  • <Request> getHeaderNames() returns (string[])

    Get all transport header names from the request.

    Return Type Description
    string[] An array of all transport header names
  • <Request> expects100Continue() returns (boolean)

    Checks whether the client expects a 100-continue response.

    Return Type Description
    boolean Returns true if the client expects a 100-continue response. If not, returns false.
  • <Request> setContentType(string contentType)

    Set the content-type header to request

    Parameter Name Data Type Default Value Description
    contentType string Content type value that needs to be set to Content-Type header
  • <Request> getContentType() returns (string)

    Get the content-type value from the request

    Return Type Description
    string Returns the content-type header value as a string.
  • <Request> getJsonPayload() returns (json | PayloadError)

    Gets the request payload in JSON format

    Return Type Description
    json | PayloadError The JSON reresentation of the message payload or 'PayloadError' in case of errors
  • <Request> getXmlPayload() returns (xml | PayloadError)

    Gets the request payload in XML format

    Return Type Description
    xml | PayloadError The XML representation of the message payload or 'PayloadError' in case of errors
  • <Request> getStringPayload() returns (string | PayloadError)

    Gets the request payload as a string

    Return Type Description
    string | PayloadError The string representation of the message payload or 'PayloadError' in case of errors
  • <Request> getBinaryPayload() returns (blob | PayloadError)

    Gets the request payload in blob format

    Return Type Description
    blob | PayloadError The blob representation of the message payload or 'PayloadError' in case of errors
  • <Request> getByteChannel() returns (ioByteChannel | PayloadError)

    Get the request payload as a byte channel except for multiparts. In case of multiparts, please use 'getBodyParts()' instead.

    Return Type Description
    ioByteChannel | PayloadError A byte channel as the message payload or 'PayloadError' in case of errors
  • <Request> getFormParams() returns (map<string> | PayloadError)

    Gets the form parameters from the HTTP request as a map

    Return Type Description
    map<string> | PayloadError The map of form params or 'PayloadError' in case of errors
  • <Request> getBodyParts() returns (Entity[] | mimeEntityError)

    Get multiparts from request

    Return Type Description
    Entity[] | mimeEntityError Returns the body parts as an array of entities
  • <Request> setJsonPayload(json payload)

    Sets a JSON as the request payload

    Parameter Name Data Type Default Value Description
    payload json The JSON payload to be set to the request
  • <Request> setXmlPayload(xml payload)

    Sets an XML as the payload

    Parameter Name Data Type Default Value Description
    payload xml The XML payload object
  • <Request> setStringPayload(string payload)

    Sets a string as the request payload

    Parameter Name Data Type Default Value Description
    payload string The payload to be set to the request as a string
  • <Request> setBinaryPayload(blob payload)

    Sets a blob as the request payload

    Parameter Name Data Type Default Value Description
    payload blob The blob representation of the message payload
  • <Request> setBodyParts(Entity[] bodyParts)

    Set multiparts as the request payload

    Parameter Name Data Type Default Value Description
    bodyParts Entity[] Represent body parts that needs to be set to the request
  • <Request> setFileAsPayload(string filePath)

    Sets the entity body of the request with the given file content

    Parameter Name Data Type Default Value Description
    filePath string Path to the file that needs to be set to the payload
  • <Request> setByteChannel(ByteChannel payload)

    Set a byte channel as the request payload

    Parameter Name Data Type Default Value Description
    payload ByteChannel The byte channel representation of the message payload
  • <Request> setPayload(string | xml | json | blob | ioByteChannel | Entity[] payload)

    Set the request payload

    Parameter Name Data Type Default Value Description
    payload string | xml | json | blob | ioByteChannel | Entity[] Payload can be of type string, xml, json, blob or byte channel

public type RequestCacheControl object

Cache control directives configuration for requests

Field Name Data Type Default Value Description
noCache boolean false Represents the no-cache directive
noStore boolean false Represents the no-store directive
noTransform boolean true Represents the no-transform directive
onlyIfCached boolean false Represents the only-if-cached directive
maxAge int -1 Represents the max-age directive
maxStale int -1 Represents the max-stale directive
minFresh int -1 Represents the min-fresh directive
  • <RequestCacheControl> buildCacheControlDirectives() returns (string)

    Build the cache control directives string from the current request cache control configurations

    Return Type Description
    string

public type Response object

Represents an HTTP response message

Field Name Data Type Default Value Description
statusCode int The response status code
reasonPhrase string The status code reason phrase
server string The server header
cacheControl ResponseCacheControl The cache control directives configuration of the response
  • <Response> getEntity() returns (mimeEntity | mimeEntityError)

    Get the entity from the response with the body

    Return Type Description
    mimeEntity | mimeEntityError Entity of the response
  • <Response> getEntityWithoutBody() returns (Entity)

    Get the entity from the response without the body

    Return Type Description
    Entity Entity of the response
  • <Response> setEntity(Entity entity)

    Set the entity to response

    Parameter Name Data Type Default Value Description
    entity Entity
  • <Response> hasHeader(string headerName) returns (boolean)

    Check whether the requested header exists

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    boolean Boolean representing the existence of a given header
  • <Response> getHeader(string headerName) returns (string)

    Returns the header value with the specified header name. If there are more than one header value for the specified header name, the first value is returned.

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    string The first header value struct for the provided header name. Returns null if the header does not exist.
  • <Response> addHeader(string headerName, string headerValue)

    Adds the specified key/value pair as an HTTP header to the outbound response

    Parameter Name Data Type Default Value Description
    headerName string The header name
    headerValue string The header value
  • <Response> getHeaders(string headerName) returns (string[])

    Gets the HTTP headers from the inbound response

    Parameter Name Data Type Default Value Description
    headerName string The header name
    Return Type Description
    string[] The header values struct array for a given header name
  • <Response> setHeader(string headerName, string headerValue)

    Sets the value of a transport header

    Parameter Name Data Type Default Value Description
    headerName string The header name
    headerValue string The header value
  • <Response> removeHeader(string key)

    Removes a transport header from the response

    Parameter Name Data Type Default Value Description
    key string The header name
  • <Response> removeAllHeaders()

    Removes all transport headers from the response

  • <Response> getHeaderNames() returns (string[])

    Get all transport header names from the response.

    Return Type Description
    string[] An array of all transport header names
  • <Response> setContentType(string contentType)

    Set the content-type header to response

    Parameter Name Data Type Default Value Description
    contentType string Content type value that needs to be set to Content-Type header
  • <Response> getContentType() returns (string)

    Get the content-type value from the response

    Return Type Description
    string Returns the content-type header value as a string.
  • <Response> getJsonPayload() returns (json | PayloadError)

    Gets the response payload in JSON format

    Return Type Description
    json | PayloadError The JSON reresentation of the message payload or 'PayloadError' in case of errors
  • <Response> getXmlPayload() returns (xml | PayloadError)

    Gets the response payload in XML format

    Return Type Description
    xml | PayloadError The XML representation of the message payload or 'PayloadError' in case of errors
  • <Response> getStringPayload() returns (string | PayloadError)

    Gets the response payload as a string

    Return Type Description
    string | PayloadError The string representation of the message payload or 'PayloadError' in case of errors
  • <Response> getBinaryPayload() returns (blob | PayloadError)

    Gets the response payload in blob format

    Return Type Description
    blob | PayloadError The blob representation of the message payload or 'PayloadError' in case of errors
  • <Response> getByteChannel() returns (ioByteChannel | PayloadError)

    Gets the response payload as a byte channel except for multiparts. In case of multiparts, please use 'getBodyParts()' instead.

    Return Type Description
    ioByteChannel | PayloadError A byte channel as the message payload or 'PayloadError' in case of errors
  • <Response> getBodyParts() returns (Entity[] | mimeEntityError)

    Get multiparts from response

    Return Type Description
    Entity[] | mimeEntityError Returns the body parts as an array of entities
  • <Response> setETag(json | xml | string | blob payload)

    Sets the ETag header for the given payload. The ETag is generated using a CRC32 hash function.

    Parameter Name Data Type Default Value Description
    payload json | xml | string | blob
  • <Response> setLastModified()

    Sets the current time as the Last-Modified header.

  • <Response> setJsonPayload(json payload)

    Sets a JSON as the outbound response payload

    Parameter Name Data Type Default Value Description
    payload json The JSON payload object
  • <Response> setXmlPayload(xml payload)

    Sets an XML as the outbound response payload

    Parameter Name Data Type Default Value Description
    payload xml The XML payload object
  • <Response> setStringPayload(string payload)

    Sets a string as the outbound response payload

    Parameter Name Data Type Default Value Description
    payload string The payload to be set to the response as a string
  • <Response> setBinaryPayload(blob payload)

    Sets a blob as the outbound response payload

    Parameter Name Data Type Default Value Description
    payload blob The blob representation of the message payload
  • <Response> setBodyParts(Entity[] bodyParts)

    Set multiparts as the response payload

    Parameter Name Data Type Default Value Description
    bodyParts Entity[] Represent body parts that needs to be set to the response
  • <Response> setFileAsPayload(string filePath)

    Sets the entity body of the outbound response with the given file content

    Parameter Name Data Type Default Value Description
    filePath string Path to the file that needs to be set to the payload
  • <Response> setByteChannel(ByteChannel payload)

    Sets a byte channel as the outbound response payload

    Parameter Name Data Type Default Value Description
    payload ByteChannel The byte channel representation of the message payload
  • <Response> setPayload(string | xml | json | blob | ioByteChannel | Entity[] payload)

    Set the response payload

    Parameter Name Data Type Default Value Description
    payload string | xml | json | blob | ioByteChannel | Entity[] Payload can be of type string, xml, json, blob, byte channel or set of body parts

public type ResponseCacheControl object

Cache control directives configuration for responses

Field Name Data Type Default Value Description
mustRevalidate boolean false Represents the must-revalidate directive
noCache boolean false Represents the no-cache directive
noStore boolean false Represents the no-store directive
noTransform boolean true Represents the no-transform directive
isPrivate boolean false Represents the private and public directives
proxyRevalidate boolean false Represents the proxy-revalidate directive
maxAge int -1 Represents the max-age directive
sMaxAge int -1 Represents the s-maxage directive
noCacheFields string[] [] Optional fields for no-cache directive. If sending any of the listed fields in a response, they must validated with the origin server.
privateFields string[] [] Optional fields for private directive. A cache can omit the fields specified and store the rest of the response.
  • <ResponseCacheControl> buildCacheControlDirectives() returns (string)

    Build the cache control directives string from the current response cache control configurations

    Return Type Description
    string

public type RetryClient object

Represents an HTTP Retry client to be used with the HTTP client to provide retrying over HTTP requests.

Field Name Data Type Default Value Description
serviceUri string
  • Target service url.
config ClientEndpointConfig
  • HTTP ClientEndpointConfig to be used for HTTP client invocation.
retryConfig RetryConfig
  • Retry related configuration.
httpClient CallerActions
  • HTTP client for outbound HTTP requests.
  • <RetryClient> post(string path) returns (Response | HttpConnectorError)

        The POST function implementation of the HTTP retry client. Protects the invocation of the POST function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    path string

    Target service url.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> head(string path) returns (Response | HttpConnectorError)

        The HEAD function implementation of the HTTP retry client. Protects the invocation of the HEAD function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    path string

    Target service url.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> put(string path) returns (Response | HttpConnectorError)

        The PUT function implementation of the HTTP retry client. Protects the invocation of the PUT function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    path string

    Target service url.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> forward(string path, Request request) returns (Response | HttpConnectorError)

        The FORWARD function implementation of the HTTP retry client. Protects the invocation of the FORWARD function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    path string

    Target service url.

    request Request

    A request message.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> execute(string httpVerb, string path, Request request) returns (Response | HttpConnectorError)

        The EXECUTE function implementation of the HTTP retry client. Protects the invocation of the EXECUTE function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    httpVerb string

    HTTP verb to be used for the request.

    path string

    Target service url.

    request Request

    A request message.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> patch(string path) returns (Response | HttpConnectorError)

        The PATCH function implementation of the HTTP retry client. Protects the invocation of the PATCH function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    path string

    Target service url.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> delete(string path) returns (Response | HttpConnectorError)

        The DELETE function implementation of the HTTP retry client. Protects the invocation of the DELETE function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    path string

    Target service url.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> get(string path) returns (Response | HttpConnectorError)

        The GET function implementation of the HTTP retry client. Protects the invocation of the GET function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    path string

    Target service url.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> options(string path) returns (Response | HttpConnectorError)

        The OPTIONS function implementation of the HTTP retry client. Protects the invocation of the OPTIONS function
        attached to the underlying HTTP client.
    

    Parameter Name Data Type Default Value Description
    path string

    Target service url.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> submit(string httpVerb, string path, Request request) returns (HttpFuture | HttpConnectorError)

        The SUBMIT function implementation of the HTTP retry client.
    

    Parameter Name Data Type Default Value Description
    httpVerb string

    HTTP verb to be used for the request.

    path string

    Target service url.

    request Request

    A request message.

    Return Type Description
    HttpFuture | HttpConnectorError
  • <RetryClient> getResponse(HttpFuture httpFuture) returns (Response | HttpConnectorError)

        The getResponse function implementation of the HTTP retry client.
    

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture

    -The Future which relates to previous async invocation.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> hasPromise(HttpFuture httpFuture) returns (boolean)

        The hasPromise function implementation of the HTTP retry client.
    

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture

    The Future which relates to previous async invocation.

    Return Type Description
    boolean
  • <RetryClient> getNextPromise(HttpFuture httpFuture) returns (PushPromise | HttpConnectorError)

        The getNextPromise function implementation of the HTTP retry client.
    

    Parameter Name Data Type Default Value Description
    httpFuture HttpFuture

    The Future which relates to previous async invocation.

    Return Type Description
    PushPromise | HttpConnectorError
  • <RetryClient> getPromisedResponse(PushPromise promise) returns (Response | HttpConnectorError)

        The getPromisedResponse function implementation of the HTTP retry client.
    

    Parameter Name Data Type Default Value Description
    promise PushPromise

    The related Push Promise message.

    Return Type Description
    Response | HttpConnectorError
  • <RetryClient> rejectPromise(PushPromise promise)

        The rejectPromise function implementation of the HTTP retry client.
    

    Parameter Name Data Type Default Value Description
    promise PushPromise

    The Push Promise need to be rejected.

public type SecureListener object

Representation of an Secure Listener

Field Name Data Type Default Value Description
config SecureEndpointConfiguration SecureEndpointConfiguration instance
httpListener Listener HTTP Listener instance
  • <SecureListener> init(SecureEndpointConfiguration config)

    Parameter Name Data Type Default Value Description
    config SecureEndpointConfiguration
  • <SecureListener> initEndpoint() returns (error)

    Gets called when the endpoint is being initialize during package init time

    Return Type Description
    error Error occured during initialization
  • <SecureListener> register(typedesc serviceType)

    Gets called every time a service attaches itself to this endpoint. Also happens at package initialization.

    Parameter Name Data Type Default Value Description
    serviceType typedesc The type of the service to be registered
  • <SecureListener> start()

    Starts the registered service

  • <SecureListener> getCallerActions() returns (Connection)

    Returns the connector that client code uses

    Return Type Description
    Connection The connector that client code uses
  • <SecureListener> stop()

    Stops the registered service

public type Service object

  • <Service> getEndpoint() returns (Listener)

    Return Type Description
    Listener

public type WebSocketClient object

Field Name Data Type Default Value Description
id string
negotiatedSubProtocol string
isSecure boolean
isOpen boolean
attributes map
  • <WebSocketClient> init(WebSocketClientEndpointConfig config)

    Gets called when the endpoint is being initialize during package init time

    Parameter Name Data Type Default Value Description
    config WebSocketClientEndpointConfig The ServiceEndpointConfiguration of the endpoint
  • <WebSocketClient> initEndpoint()

  • <WebSocketClient> register(typedesc serviceType)

    gets called every time a service attaches itself to this endpoint - also happens at package init time

    Parameter Name Data Type Default Value Description
    serviceType typedesc
  • <WebSocketClient> getCallerActions() returns (WebSocketConnector)

    Returns the connector that client code uses

    Return Type Description
    WebSocketConnector The connector that client code uses
  • <WebSocketClient> start()

    Starts the registered service

  • <WebSocketClient> stop()

    Stops the registered service

public type WebSocketClientService object

  • <WebSocketClientService> getEndpoint() returns (WebSocketClient)

    Return Type Description
    WebSocketClient

public type WebSocketConnector object

Represents a WebSocket connector in ballerina. This include all connector oriented operations.

  • <WebSocketConnector> pushText(string text) returns (WebSocketConnectorError | null)

    Push text to the connection

    Parameter Name Data Type Default Value Description
    text string Text to be sent
    Return Type Description
    WebSocketConnectorError | null
  • <WebSocketConnector> pushBinary(blob data) returns (WebSocketConnectorError | null)

    Push binary data to the connection

    Parameter Name Data Type Default Value Description
    data blob Binary data to be sent
    Return Type Description
    WebSocketConnectorError | null
  • <WebSocketConnector> ping(blob data) returns (WebSocketConnectorError | null)

    Ping the connection

    Parameter Name Data Type Default Value Description
    data blob Binary data to be sent
    Return Type Description
    WebSocketConnectorError | null
  • <WebSocketConnector> pong(blob data) returns (WebSocketConnectorError | null)

    Send pong message to the connection

    Parameter Name Data Type Default Value Description
    data blob Binary data to be sent
    Return Type Description
    WebSocketConnectorError | null
  • <WebSocketConnector> close(int statusCode, string reason) returns (WebSocketConnectorError | null)

    Close the connection

    Parameter Name Data Type Default Value Description
    statusCode int Status code for closing the connection
    reason string Reason for closing the connection
    Return Type Description
    WebSocketConnectorError | null
  • <WebSocketConnector> ready() returns (WebSocketConnectorError | null)

    Return Type Description
    WebSocketConnectorError | null

public type WebSocketConnectorError object

WebSocketConnectorError struct represents an error occured during WebSocket message transfers

Field Name Data Type Default Value Description
message string
cause error

public type WebSocketListener object

Field Name Data Type Default Value Description
id string
negotiatedSubProtocol string
isSecure boolean
isOpen boolean
attributes map
  • <WebSocketListener> init(ServiceEndpointConfiguration config)

    Gets called when the endpoint is being initialize during package init time

    Parameter Name Data Type Default Value Description
    config ServiceEndpointConfiguration The ServiceEndpointConfiguration of the endpoint
  • <WebSocketListener> register(typedesc serviceType)

    gets called every time a service attaches itself to this endpoint - also happens at package init time

    Parameter Name Data Type Default Value Description
    serviceType typedesc
  • <WebSocketListener> start()

    Starts the registered service

  • <WebSocketListener> getCallerActions() returns (WebSocketConnector)

    Returns the connector that client code uses

    Return Type Description
    WebSocketConnector The connector that client code uses
  • <WebSocketListener> stop()

    Stops the registered service

public type WebSocketService object

  • <WebSocketService> getEndpoint() returns (WebSocketListener)

    Return Type Description
    WebSocketListener