http Binding
http Binding
Defines a binding with http protocol support, with server or client behavior.
server
The server kind http binding decodes HTTP/1.1 protocol or HTTP/2 protocol on the inbound network stream, producing higher level application streams for each request.
Cross-Origin Resource Sharing (CORS) is supported by specifying an access control policy of cross-origin. Further configuration allows for finer-grained access control including specific request origins, methods and headers allowed, and specific response headers exposed.
Authorization is enforced by a guard and the credentials can be extracted from a cookie, header or query parameter.
Conditional routes based on http request headers are used to route these application streams to an exit binding.
http_server:
type: http
kind: server
options:
access-control:
policy: cross-origin
authorization:
my_jwt_guard:
credentials:
headers:
authorization: Bearer {credentials}
routes:
- when:
- headers:
":scheme": https
":authority": example.com:443
exit: echo_serverclient
The client kind http binding receives inbound application streams and encodes each request as a network stream via HTTP/1.1 protocol. Note that the same network stream can be reused to encode multiple HTTP/1.1 requests.
Conditional routes based on http request headers are used to route these network streams to an exit binding.
http_client:
type: http
kind: client
options:
versions:
- h2
exit: tcp_client
