Files
skybridge/faas/examples/hello-world
2025-08-30 23:52:37 -04:00
..
2025-08-30 23:52:37 -04:00
2025-08-30 23:52:37 -04:00
2025-08-30 23:52:37 -04:00
2025-08-30 23:52:37 -04:00
2025-08-30 23:52:37 -04:00

Hello World Function Example

This is a simple example function that demonstrates how to create and deploy functions in the Skybridge FaaS platform.

Function Description

The function takes a JSON input with an optional name field and returns a greeting message.

Input Format

{
  "name": "John"
}

Output Format

{
  "message": "Hello, John!",
  "input": {
    "name": "John"
  }
}

Building the Function

To build the function as a Docker image:

docker build -t hello-world-function .

Testing the Function Locally

To test the function locally:

# Test with a name
docker run -e FUNCTION_INPUT='{"name": "Alice"}' hello-world-function

# Test without a name (defaults to "World")
docker run hello-world-function

Deploying to Skybridge FaaS

Once you have the Skybridge FaaS platform running, you can deploy this function using the API:

  1. Create the function:
curl -X POST http://localhost:8083/api/functions \
  -H "Content-Type: application/json" \
  -H "X-User-Email: test@example.com" \
  -d '{
    "name": "hello-world",
    "image": "hello-world-function",
    "runtime": "custom",
    "memory": 128,
    "timeout": "30s"
  }'
  1. Deploy the function:
curl -X POST http://localhost:8083/api/functions/{function-id}/deploy \
  -H "X-User-Email: test@example.com"
  1. Execute the function:
curl -X POST http://localhost:8083/api/functions/{function-id}/execute \
  -H "Content-Type: application/json" \
  -H "X-User-Email: test@example.com" \
  -d '{"input": {"name": "Bob"}}'