Compiles a JavaScript event function to a jsEventTask object.
(ctx context.Context, funcSource string)
| 105 | |
| 106 | // Compiles a JavaScript event function to a jsEventTask object. |
| 107 | func newJsEventTask(ctx context.Context, funcSource string) (sgbucket.JSServerTask, error) { |
| 108 | eventTask := &jsEventTask{} |
| 109 | err := eventTask.InitWithLogging(funcSource, 0, |
| 110 | func(s string) { |
| 111 | base.ErrorfCtx(ctx, base.KeyJavascript.String()+": Webhook %s", base.UD(s)) |
| 112 | }, |
| 113 | func(s string) { base.InfofCtx(ctx, base.KeyJavascript, "Webhook %s", base.UD(s)) }) |
| 114 | if err != nil { |
| 115 | return nil, err |
| 116 | } |
| 117 | |
| 118 | eventTask.After = func(result otto.Value, err error) (interface{}, error) { |
| 119 | nativeValue, _ := result.Export() |
| 120 | return nativeValue, err |
| 121 | } |
| 122 | |
| 123 | return eventTask, nil |
| 124 | } |
| 125 | |
| 126 | //////// JSEventFunction |
| 127 |
no test coverage detected