Add Decoder Registry

Add Raw Decoder
This commit is contained in:
Emmm Monster
2020-12-26 15:47:10 +08:00
parent 1aa5731225
commit d5031e1935
8 changed files with 123 additions and 11 deletions

12
algo/common/dispatch.go Normal file
View File

@ -0,0 +1,12 @@
package common
type NewDecoderFunc func([]byte) Decoder
var decoderRegistry = make(map[string][]NewDecoderFunc)
func RegisterDecoder(ext string, dispatchFunc NewDecoderFunc) {
decoderRegistry[ext] = append(decoderRegistry[ext], dispatchFunc)
}
func GetDecoder(ext string) []NewDecoderFunc {
return decoderRegistry[ext]
}