From 4ac40dc74cbc1333e34a1bcef4e70dd25d62d149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A5=C3=A5vi?= Date: Fri, 21 Feb 2025 10:33:35 +0100 Subject: [PATCH 1/2] Expose dsd.Dump without Identifier --- dsd/dsd.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dsd/dsd.go b/dsd/dsd.go index f04a7c9..ae6e276 100644 --- a/dsd/dsd.go +++ b/dsd/dsd.go @@ -93,7 +93,7 @@ func Dump(t interface{}, format uint8) ([]byte, error) { // DumpIndent stores the interface as a dsd formatted data structure with indentation, if available. func DumpIndent(t interface{}, format uint8, indent string) ([]byte, error) { - data, err := dumpWithoutIdentifier(t, format, indent) + data, err := DumpWithoutIdentifier(t, format, indent) if err != nil { return nil, err } @@ -102,7 +102,8 @@ func DumpIndent(t interface{}, format uint8, indent string) ([]byte, error) { return append(varint.Pack8(format), data...), nil } -func dumpWithoutIdentifier(t interface{}, format uint8, indent string) ([]byte, error) { +// DumpWithoutIdentifier stores the interface as a data structure, without format identifier, but with indentation, if specified and available. +func DumpWithoutIdentifier(t interface{}, format uint8, indent string) ([]byte, error) { format, ok := ValidateSerializationFormat(format) if !ok { return nil, ErrIncompatibleFormat From 52f9389a1ade52da31695c7cffe49b88d8aa1d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A5=C3=A5vi?= Date: Fri, 21 Feb 2025 09:51:51 +0000 Subject: [PATCH 2/2] Fix missing changes --- dsd/http.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dsd/http.go b/dsd/http.go index 85aab16..de05862 100644 --- a/dsd/http.go +++ b/dsd/http.go @@ -65,7 +65,7 @@ func DumpToHTTPRequest(r *http.Request, t interface{}, format uint8) error { } // Serialize data. - data, err := dumpWithoutIdentifier(t, format, "") + data, err := DumpWithoutIdentifier(t, format, "") if err != nil { return fmt.Errorf("dsd: failed to serialize: %w", err) } @@ -117,7 +117,7 @@ func MimeDump(t any, accept string) (data []byte, mimeType string, format uint8, } // Serialize and return. - data, err = dumpWithoutIdentifier(t, format, "") + data, err = DumpWithoutIdentifier(t, format, "") return data, mimeType, format, err }