diff options
Diffstat (limited to 'services/webhook/payloader.go')
-rw-r--r-- | services/webhook/payloader.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/services/webhook/payloader.go b/services/webhook/payloader.go index 54a11a5868..ab280a25b6 100644 --- a/services/webhook/payloader.go +++ b/services/webhook/payloader.go @@ -30,16 +30,15 @@ type payloadConvertor[T any] interface { Package(*api.PackagePayload) (T, error) } -func convertUnmarshalledJSON[T, P any](convert func(P) (T, error), data []byte) (T, error) { +func convertUnmarshalledJSON[T, P any](convert func(P) (T, error), data []byte) (t T, err error) { var p P - if err := json.Unmarshal(data, &p); err != nil { - var t T + if err = json.Unmarshal(data, &p); err != nil { return t, fmt.Errorf("could not unmarshal payload: %w", err) } return convert(p) } -func newPayload[T any](rc payloadConvertor[T], data []byte, event webhook_module.HookEventType) (T, error) { +func newPayload[T any](rc payloadConvertor[T], data []byte, event webhook_module.HookEventType) (t T, err error) { switch event { case webhook_module.HookEventCreate: return convertUnmarshalledJSON(rc.Create, data) @@ -79,7 +78,6 @@ func newPayload[T any](rc payloadConvertor[T], data []byte, event webhook_module case webhook_module.HookEventPackage: return convertUnmarshalledJSON(rc.Package, data) } - var t T return t, fmt.Errorf("newPayload unsupported event: %s", event) } |