mirror of
https://github.com/gabehf/GoLambda.git
synced 2026-03-07 13:38:12 -08:00
Initial Commit
This commit is contained in:
commit
684f9bf797
3 changed files with 42 additions and 0 deletions
5
go.mod
Normal file
5
go.mod
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
module github.com/mnrva-dev/GoLambda
|
||||
|
||||
go 1.17
|
||||
|
||||
require github.com/aws/aws-lambda-go v1.37.0 // indirect
|
||||
2
go.sum
Normal file
2
go.sum
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
github.com/aws/aws-lambda-go v1.37.0 h1:WXkQ/xhIcXZZ2P5ZBEw+bbAKeCEcb5NtiYpSwVVzIXg=
|
||||
github.com/aws/aws-lambda-go v1.37.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM=
|
||||
35
main.go
Normal file
35
main.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// main.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/aws/aws-lambda-go/lambda"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
A int
|
||||
B int
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Result int
|
||||
}
|
||||
|
||||
func GCF(a, b int) int {
|
||||
for b != 0 {
|
||||
t := b
|
||||
b = a % b
|
||||
a = t
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func HandleRequests(ctx context.Context, req Request) (Response, error) {
|
||||
return Response{Result: GCF(req.A, req.B)}, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Make the handler available for Remote Procedure Call by AWS Lambda
|
||||
lambda.Start(HandleRequests)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue