summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/encode
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/encode')
-rw-r--r--modules/caddyhttp/encode/caddyfile.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/modules/caddyhttp/encode/caddyfile.go b/modules/caddyhttp/encode/caddyfile.go
index 9d9646c..2f11ca0 100644
--- a/modules/caddyhttp/encode/caddyfile.go
+++ b/modules/caddyhttp/encode/caddyfile.go
@@ -64,21 +64,14 @@ func (enc *Encode) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
for d.NextBlock(0) {
name := d.Val()
- mod, err := caddy.GetModule("http.encoders." + name)
- if err != nil {
- return fmt.Errorf("getting encoder module '%s': %v", name, err)
- }
- unm, ok := mod.New().(caddyfile.Unmarshaler)
- if !ok {
- return fmt.Errorf("encoder module '%s' is not a Caddyfile unmarshaler", mod)
- }
- err = unm.UnmarshalCaddyfile(d.NewFromNextSegment())
+ modID := "http.encoders." + name
+ unm, err := caddyfile.UnmarshalModule(d, modID)
if err != nil {
return err
}
encoding, ok := unm.(Encoding)
if !ok {
- return fmt.Errorf("module %s is not an HTTP encoding", mod)
+ return fmt.Errorf("module %s is not an HTTP encoding; is %T", modID, unm)
}
if enc.EncodingsRaw == nil {
enc.EncodingsRaw = make(caddy.ModuleMap)