From b26d6370f5b0a44ff8acfadf55a609ef1f23c0ae Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 15 Oct 2024 21:01:40 +0200 Subject: [PATCH] Add newInlineOtherContent --- inlineOtherContent.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/inlineOtherContent.go b/inlineOtherContent.go index d55bc8d..7c7c650 100644 --- a/inlineOtherContent.go +++ b/inlineOtherContent.go @@ -1,11 +1,23 @@ package atomfeed -import "errors" +import ( + "errors" + "fmt" + "mime" +) type InlineOtherContent struct { *CommonAttributes + AnyElement any `xml:"anyelement,omitempty"` Type MediaType `xml:"type,attr,omitempty"` - AnyElement []*any `xml:"anyelement,omitempty"` +} + +func newInlineOtherContent(mediaType string, content any) (*InlineOtherContent, error) { + if mediaType, _, err := mime.ParseMediaType(mediaType); err != nil { + return nil, fmt.Errorf("media type %v incompatible with inline other content", mediaType) + } + + return &InlineOtherContent{Type: MediaType(mediaType), AnyElement: content}, nil } func (i *InlineOtherContent) isContent() bool { return true }