DecryptDecode returns a decode function that can be passed to NewDecoder when decoding an encrypted message (https://godoc.org/gocloud.dev/secrets). post defaults to BytesDecode. An optional decoder can be passed in to do further decode operation based on the decrypted message.
(k *secrets.Keeper, post Decode)
| 482 | // post defaults to BytesDecode. An optional decoder can be passed in to do |
| 483 | // further decode operation based on the decrypted message. |
| 484 | func DecryptDecode(k *secrets.Keeper, post Decode) Decode { |
| 485 | return func(ctx context.Context, b []byte, obj any) error { |
| 486 | decrypted, err := k.Decrypt(ctx, b) |
| 487 | if err != nil { |
| 488 | return err |
| 489 | } |
| 490 | if post == nil { |
| 491 | return BytesDecode(ctx, decrypted, obj) |
| 492 | } |
| 493 | return post(ctx, decrypted, obj) |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | // DecoderByName returns a *Decoder based on decoderName. |
| 498 | // |