Skip to content

Commit

Permalink
Merge branch 'main' into sebsto/localserver
Browse files Browse the repository at this point in the history
  • Loading branch information
sebsto committed Nov 13, 2024
2 parents 2397b00 + c22f527 commit ce057d0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Examples/HelloJSON/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Hello JSON

This is a simple example of an AWS Lambda function that takes a JSON structure as input parameter and returns a JSON structure as response.
This is a simple example of an AWS Lambda function that takes a JSON structure as an input parameter and returns a JSON structure as a response.

The runtime takes care of decoding the input and encoding the output.

## Code

The code defines a `HelloRequest` and `HelloResponse` data structure to represent the input and outpout payload. These structures are typically shared with a client project, such as an iOS application.
The code defines `HelloRequest` and `HelloResponse` data structures to represent the input and output payloads. These structures are typically shared with a client project, such as an iOS application.

The code creates a `LambdaRuntime` struct. In it's simplest form, the initializer takes a function as argument. The function is the handler that will be invoked when an event triggers the Lambda function.
The code creates a `LambdaRuntime` struct. In it's simplest form, the initializer takes a function as an argument. The function is the handler that will be invoked when an event triggers the Lambda function.

The handler is `(event: HelloRequest, context: LambdaContext)`. The function takes two arguments:
- the event argument is a `HelloRequest`. It is the parameter passed when invoking the function.
- the context argument is a `Lambda Context`. It is a description of the runtime context.

The function return value will be encoded to an `HelloResponse` as your Lambda function response.
The function return value will be encoded to a `HelloResponse` as your Lambda function response.

## Build & Package

Expand Down
2 changes: 1 addition & 1 deletion Examples/HelloJSON/Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import AWSLambdaRuntime

// in this example we are receiving and responding with a JSON structure
// in this example we are receiving and responding with JSON structures

// the data structure to represent the input parameter
struct HelloRequest: Decodable {
Expand Down
2 changes: 1 addition & 1 deletion Examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This directory contains example code for Lambda functions.

- **[BackgroundTasks](BackgroundTasks/README.md)**: a Lambda function that continues to run background tasks after having sent the response (requires [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)).

- **[HelloJSON](HelloJSON/README.md)**: a Lambda function that accepts a JSON as input parameter and responds with a JSON output (requires [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)).
- **[HelloJSON](HelloJSON/README.md)**: a Lambda function that accepts JSON as an input parameter and responds with a JSON output (requires [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)).

- **[HelloWorld](HelloWorld/README.md)**: a simple Lambda function (requires [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)).

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ This should print
### Receive and respond with JSON objects
Typically, your Lambda functions will receive an input parameter expressed as JSON and will respond with another JSON. The Swift AWS Lambda runtime automatically takes care of encoding and decoding JSON objects when your Lambda function handler accepts `Decodable` and returns `Encodable` conforming `struct`.
Typically, your Lambda functions will receive an input parameter expressed as JSON and will respond with some other JSON. The Swift AWS Lambda runtime automatically takes care of encoding and decoding JSON objects when your Lambda function handler accepts `Decodable` and returns `Encodable` conforming types.
Here is an example of a minimal function that accepts a JSON object as input and responds with another JSON object.
Expand Down Expand Up @@ -220,7 +220,7 @@ You can learn how to deploy and invoke this function in [the streaming example R

### Integration with AWS Services

Most Lambda functions are triggered by events originating in other AWS services such as `Amazon SNS`, `Amazon SQS` or `AWS APIGateway`.
Most Lambda functions are triggered by events originating in other AWS services such as Amazon SNS, Amazon SQS or AWS APIGateway.

The [Swift AWS Lambda Events](http://github.com/swift-server/swift-aws-lambda-events) package includes an `AWSLambdaEvents` module that provides implementations for most common AWS event types further simplifying writing Lambda functions.

Expand Down

0 comments on commit ce057d0

Please sign in to comment.