File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
vts/compositeevidenceparser Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2026 Contributors to the Veraison project.
2+ // SPDX-License-Identifier: Apache-2.0
3+
4+ package compositeevidenceparser
5+
6+ import (
7+ "fmt"
8+ "mime"
9+ )
10+
11+ // present MediaType to Composite Parser is maintained locally within the compositeevidenceparser package
12+ var mtToCeParser = map [string ]ICompositeEvidenceParser {
13+ "application/cmw-collection+cbor" : & cmwParser {},
14+ "application/cmw-collection+json" : & cmwParser {},
15+ }
16+
17+ func GetParserFromMediaType (mt string ) (ICompositeEvidenceParser , error ) {
18+ // Check if its a valid mediaType
19+ if _ , _ , err := mime .ParseMediaType (mt ); err != nil {
20+ return nil , fmt .Errorf ("bad media type: %w" , err )
21+ }
22+ switch mt {
23+ case "application/cmw-collection+cbor" , "application/cmw-collection+json" :
24+ return mtToCeParser [mt ], nil
25+ default :
26+ return nil , fmt .Errorf ("unsupported media type:%s" , mt )
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments