Functions
authenticateResource | I Uses for declarative auth design, where the authentication/authorization decision is taken
by reading the auth annotations provided in service/resource and the |
getDeadline | I Returns the deadline value as |
getHeader | I Returns the header value with the specified header name. |
getHeaders | I Gets all the transport headers with the specified header name. |
isCancelled | I Checks whether the deadline is already exceeded or not. |
setCompression | I Enables the compression support by adding the |
setDeadline | I Enables the deadline by adding the |
authenticateResource
function authenticateResource(Service serviceRef)
Uses for declarative auth design, where the authentication/authorization decision is taken
by reading the auth annotations provided in service/resource and the Authorization
header of request.
Parameters
- serviceRef Service
The service reference where the resource locates
getDeadline
Returns the deadline value as time:Utc
. This can be used to get the deadline and propagate it to subsequent internal calls.
1time:Utc?|time:Error deadline = grpc:getDeadline(map<string|string[]> headerMap);
getHeader
Returns the header value with the specified header name. If there are more than one header values for the specified header name, the first value is returned.
1map<string|string[]> headerMap = request.headers;2string|grpc:Error result = grpc:getHeader(headerMap, "content-type");
Parameters
- headerName string
The header name
getHeaders
Gets all the transport headers with the specified header name.
1map<string|string[]> headerMap = request.headers;2string[]|grpc:Error result = grpc:getHeaders(headerMap, "content-type");
Parameters
- headerName string
The header name
isCancelled
Checks whether the deadline is already exceeded or not.
1boolean|time:Error isCancelled = grpc:isCancelled(map<string|string[]> headerMap);
setCompression
function setCompression(CompressionType compressionType, map<string | string[ ]> headerMap) returns map<string | string[ ]>
Enables the compression support by adding the grpc-encoding
header to the given headers.
1map<string|string[]> headers = grpc:setCompression(grpc:GZIP);
Parameters
- compressionType CompressionType
The compression type.
setDeadline
function setDeadline(Utc deadline, map<string | string[ ]> headerMap) returns map<string | string[ ]>
Enables the deadline by adding the deadline
header to the given headers.
1time:Utc current = time:utcNow();2time:Utc deadline = time:utcAddSeconds(current, 300);3map<string|string[]> headers = grpc:setDeadline(deadline);
Parameters
- deadline Utc
The deadline time value (this should be a specific time and not a duration)