File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed 
Examples/ServiceLifecycle Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -14,15 +14,17 @@ let package = Package(
1414    dependencies:  [ 
1515        . package ( url:  " https://github.com/vapor/postgres-nio.git " ,  from:  " 1.26.0 " ) , 
1616        . package ( url:  " https://github.com/swift-server/swift-aws-lambda-runtime.git " ,  branch:  " main " ) , 
17+         . package ( url:  " https://github.com/swift-server/swift-aws-lambda-events.git " ,  from:  " 1.0.0 " ) , 
1718        . package ( url:  " https://github.com/swift-server/swift-service-lifecycle.git " ,  from:  " 2.6.3 " ) , 
1819    ] , 
1920    targets:  [ 
2021        . executableTarget( 
2122            name:  " LambdaWithServiceLifecycle " , 
2223            dependencies:  [ 
2324                . product( name:  " PostgresNIO " ,  package :  " postgres-nio " ) , 
24-                 . product( name:  " AWSLambdaRuntime " ,  package :  " swift-aws-lambda-runtime " ) , 
2525                . product( name:  " ServiceLifecycle " ,  package :  " swift-service-lifecycle " ) , 
26+                 . product( name:  " AWSLambdaRuntime " ,  package :  " swift-aws-lambda-runtime " ) , 
27+                 . product( name:  " AWSLambdaEvents " ,  package :  " swift-aws-lambda-events " ) , 
2628            ] 
2729        ) 
2830    ] 
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ Get the API Gateway endpoint and test the function:
138138API_ENDPOINT=$( aws cloudformation describe-stacks --stack-name servicelifecycle-stack --query ' Stacks[0].Outputs[?OutputKey==`APIGatewayEndpoint`].OutputValue' ) 
139139
140140#  Test the function
141- curl -X POST -d  ' "empty string - input is not used" '   " $API_ENDPOINT " 
141+ curl " $API_ENDPOINT " 
142142``` 
143143
144144The function will:
Original file line number Diff line number Diff line change 1313//===----------------------------------------------------------------------===//
1414
1515import  AWSLambdaRuntime
16+ import  AWSLambdaEvents
1617import  Logging
1718import  PostgresNIO
1819import  ServiceLifecycle
@@ -66,7 +67,7 @@ struct LambdaFunction {
6667
6768    /// Function handler. This code is called at each function invocation
6869    /// input event is ignored in this demo.
69-     private  func  handler( event:  String ,  context:  LambdaContext )  async  ->  [ User ]  { 
70+     private  func  handler( event:  APIGatewayV2Request ,  context:  LambdaContext )  async  throws   ->  APIGatewayV2Response  { 
7071
7172        var  result :  [ User ]  =  [ ] 
7273        do  { 
@@ -89,7 +90,11 @@ struct LambdaFunction {
8990            logger. error ( " Database Error " ,  metadata:  [ " cause " :  " \( String ( reflecting:  error) ) " ] ) 
9091        } 
9192
92-         return  result
93+         return  try . init( 
94+             statusCode:  . ok, 
95+             headers:  [ " content-type " :  " application/json " ] , 
96+             encodableBody:  result
97+         ) 
9398    } 
9499
95100    /// Prepare the database
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments