issue_296 #300

Merged
vtolstov merged 4 commits from devstigneev/micro:issue_296 into master 2024-02-28 23:52:31 +03:00
2 changed files with 2 additions and 8 deletions
Showing only changes of commit e6feca2fb1 - Show all commits

View File

@ -151,13 +151,7 @@ func ContentType(ct string) Option {
} }
// Metadata pass additional metadata // Metadata pass additional metadata
func Metadata(md metadata.Metadata) Option { func Metadata(md any) Option {
return func(src interface{}) error {
return Set(src, metadata.Copy(md), ".Metadata")
}
}
func MetadataAny(md any) Option {
result := metadata.Metadata{} result := metadata.Metadata{}
switch vt := md.(type) { switch vt := md.(type) {
case metadata.Metadata: case metadata.Metadata:

View File

@ -141,7 +141,7 @@ func TestMetadataAny(t *testing.T) {
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
src := &s{} src := &s{}
var opts []options.Option var opts []options.Option
opts = append(opts, options.MetadataAny(tt.Data)) opts = append(opts, options.Metadata(tt.Data))
for _, o := range opts { for _, o := range opts {
if err := o(src); err != nil { if err := o(src); err != nil {
t.Fatal(err) t.Fatal(err)