Skip to content

Commit

Permalink
refactor: chain move into codec
Browse files Browse the repository at this point in the history
  • Loading branch information
hui.wang committed Jan 5, 2022
1 parent 92399be commit d24cbda
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
19 changes: 0 additions & 19 deletions secconf/chain.go

This file was deleted.

18 changes: 18 additions & 0 deletions secconf/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@ func (c CodecFuncChain) Apply(data []byte) (out []byte, err error) {
type CodecFunc func(data []byte) ([]byte, error)

func (f CodecFunc) Apply(data []byte) ([]byte, error) { return f(data) }

// gip => encrypt => base64
func StandardChainEncode(encrypt CodecFunc) Codec {
return CodecFuncChain([]CodecFunc{
EncoderGZip,
encrypt,
EncoderBase64,
})
}

// base64 => decrypt => gzip
func StandardChainDecode(decrypt CodecFunc) Codec {
return CodecFuncChain([]CodecFunc{
DecoderBase64,
decrypt,
DecoderGZip,
})
}

0 comments on commit d24cbda

Please sign in to comment.