Skip to content

Add section on supported content types and streaming options #405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/architecture/invocations.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ OpenFaaS For Enterprise offers authentication using JWT tokens obtained through
* [TLS with OpenFaaS](/reference/tls-openfaas)
* [Identity and Access Management (IAM)](/openfaas-pro/iam/overview/)

For functions, you should provide your own authentication mechanism, such as a shared token, OIDC, HMAC or basic authentication.
For functions, you can provide your own authentication mechanism, such as a shared token, OIDC, HMAC or basic authentication.
With [OpenFaaS Identity and Access Management (IAM)](https://docs.openfaas.com/openfaas-pro/iam/overview/) you can use the built in [function authentication](https://docs.openfaas.com/openfaas-pro/iam/function-authentication/) to protect your function endpoints.

## FAQ

Expand Down
34 changes: 34 additions & 0 deletions docs/reference/workloads.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,37 @@ fprocess=env
HOME=/home/app
Http_X_Forwarded_Proto=https
```

### Supported content types

OpenFaaS supports workloads over HTTP, and most standard content types are supported.

Since OpenFaaS has no hard limit on function execution duration, it allows for maintaining long-lived connections for streaming over HTTP.

> **Important**: Always ensure OpenFaaS system and function timeouts are configured appropriately for your streaming workloads. See [Extended timeouts](https://docs.openfaas.com/tutorials/expanded-timeouts/) for details.

Supported streaming options:

**Server-Sent Events (SSE)**

Server-Sent Events enable a function to push one-way event streams to a client.

- Clients should include an `Accept: text/event-stream` header in their request when starting tht SSE request.
- The function's response `Content-Type` header must be set to `text/event-stream`. Each event data chunk should be prefixed with data: and terminated by two newline characters (\n\n).

For more details on SSE, refer to [Using Server Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)

**WebSockets**

WebSockets provide bidirectional, full-duplex communication between a client and an OpenFaaS function.

To create a WebSocket-enabled function, you can modify an existing OpenFaaS template or use the `Dockerfile` template as a starting point.

For a comprehensive guide, check out: [How to Integrate WebSockets with Serverless Functions and OpenFaaS](https://www.openfaas.com/blog/serverless-websockets/)

**Newline Delimited JSON (NDJSON)**

NDJSON (or JSON Lines) is a format for streaming multiple independent JSON objects, each on a new line.

- Clients should include an `Accept: application/x-ndjson` header in their request.
- The function's response `Content-Type` header should be set to `application/x-ndjson`. Each line in the response should be a complete JSON object followed by a newline character (\n).