@@ -28,20 +28,44 @@ type handlerOptions struct {
2828type Option func (* handlerOptions )
2929
3030// WithContext is a HandlerOption that sets the base context for all invocations of the handler.
31+ //
32+ // Usage:
33+ // lambda.StartWithOptions(
34+ // func (ctx context.Context) (string, error) {
35+ // return ctx.Value("foo"), nil
36+ // },
37+ // lambda.WithContext(context.WithValue(context.Background(), "foo", "bar"))
38+ // )
3139func WithContext (ctx context.Context ) Option {
3240 return Option (func (h * handlerOptions ) {
3341 h .baseContext = ctx
3442 })
3543}
3644
3745// WithSetEscapeHTML sets the SetEscapeHTML argument on the underlying json encoder
46+ //
47+ // Usage:
48+ // lambda.StartWithOptions(
49+ // func () (string, error) {
50+ // return "<html><body>hello!></body></html>", nil
51+ // },
52+ // lambda.WithSetEscapeHTML(true),
53+ // )
3854func WithSetEscapeHTML (escapeHTML bool ) Option {
3955 return Option (func (h * handlerOptions ) {
4056 h .jsonResponseEscapeHTML = escapeHTML
4157 })
4258}
4359
4460// WithSetIndent sets the SetIndent argument on the underling json encoder
61+ //
62+ // Usage:
63+ // lambda.StartWithOptions(
64+ // func (event any) (any, error) {
65+ // return event, nil
66+ // },
67+ // lambda.WithSetIndent(">"," "),
68+ // )
4569func WithSetIndent (prefix , indent string ) Option {
4670 return Option (func (h * handlerOptions ) {
4771 h .jsonResponseIndentPrefix = prefix
0 commit comments