From 2954045cb28ea8cbf4dbd019355a2df8fed28ccc Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Tue, 15 Sep 2020 23:17:06 +0200 Subject: Refactor gzip decoder, added parsers with reproducers --- parsers/parser.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 parsers/parser.go (limited to 'parsers/parser.go') diff --git a/parsers/parser.go b/parsers/parser.go new file mode 100644 index 0000000..06cc0dc --- /dev/null +++ b/parsers/parser.go @@ -0,0 +1,28 @@ +package parsers + +type Parser interface { + TryParse(content []byte) Metadata + +} + +type Metadata interface { +} + +type BasicMetadata struct { + Type string `json:"type"` +} + +var parsers = []Parser{ // order matter + HttpRequestParser{}, + HttpResponseParser{}, +} + +func Parse(content []byte) Metadata { + for _, parser := range parsers { + if metadata := parser.TryParse(content); metadata != nil { + return metadata + } + } + + return nil +} -- cgit v1.2.3-70-g09d2