mirror of https://github.com/gabehf/GoLambda.git
commit
684f9bf797
@ -0,0 +1,5 @@
|
||||
module github.com/mnrva-dev/GoLambda
|
||||
|
||||
go 1.17
|
||||
|
||||
require github.com/aws/aws-lambda-go v1.37.0 // indirect
|
||||
@ -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=
|
||||
@ -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…
Reference in new issue