-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.go
46 lines (40 loc) · 1.18 KB
/
function.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package serverfull
import (
"github.com/aws/aws-lambda-go/lambda"
)
// LambdaFunction is a small wrapper around the lambda.Handler
// that preserves the original signature of the function for later
// retrieval.
type LambdaFunction struct {
lambda.Handler
source interface{}
errors []error
}
// Source returns the original function signature.
func (f *LambdaFunction) Source() interface{} {
return f.source
}
// Errors returns a list of errors the Lambda might return. This is
// only populated if the function was constructed using the
// NewFunctionWithErrors constructor.
func (f *LambdaFunction) Errors() []error {
return f.errors
}
// NewFunctionWithErrors allows for documenting the various error types that
// can be returned by the function. This may be used when running in mock + http
// build modes to trigger exceptions.
func NewFunctionWithErrors(v interface{}, errors ...error) Function {
return &LambdaFunction{
Handler: lambda.NewHandler(v),
source: v,
errors: errors,
}
}
// NewFunction is a replacement for lambda.NewHandler that returns
// a Function.
func NewFunction(v interface{}) Function {
return &LambdaFunction{
Handler: lambda.NewHandler(v),
source: v,
}
}