Skip to content

Set default encoding if only one encoder is registered #196

@abemedia

Description

@abemedia

e.g. in api.go:

        if c.DefaultEncoding == "" {
-               c.DefaultEncoding = DefaultEncoding
+               switch len(encoders) {
+               case 0:
+                       panic("no encoders available")
+               case 1:
+                       for key := range encoders {
+                               c.DefaultEncoding = key
+                       }
+               default:
+                       c.DefaultEncoding = DefaultEncoding
+               }
+       }
+
+       if _, ok := encoders[c.DefaultEncoding]; !ok {
+               panic("no encoder available for default: " + c.DefaultEncoding)
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions