@marcel91200 / caddy Mirror · read-only / commits / a496308f
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

httpcaddyfile: Let modules add listener wrappers (#3397)

* httpcaddyfile: allow modules to customize listener wrappers * Update caddyconfig/httpcaddyfile/httptype.go Co-authored-by: Matt Holt <mholt@users.noreply.github.com> * Update caddyconfig/httpcaddyfile/httptype.go Co-authored-by: Matt Holt <mholt@users.noreply.github.com> * Update caddyconfig/httpcaddyfile/httptype.go Co-authored-by: Matt Holt <mholt@users.noreply.github.com> * Update caddyconfig/httpcaddyfile/httptype.go Co-authored-by: Matt Holt <mholt@users.noreply.github.com> Co-authored-by: Matt Holt <mholt@users.noreply.github.com>

Georges Haidar committed Jun 1, 2020 at 16:50 UTC a496308f6eb57f8dd2e1598bfb624a3e567aa4e1
1 file changed +14
caddyconfig/httpcaddyfile/httptype.go
+14
@@ -465,6 +465,20 @@ func (st *ServerType) serversFromPairings(
465 (addr.Port == httpsPort || (addr.Port != httpPort && addr.Host != ""))
466 }
467
468 + // Look for any config values that provide listener wrappers on the server block
469 + for _, listenerConfig := range sblock.pile["listener_wrapper"] {
470 + listenerWrapper, ok := listenerConfig.Value.(caddy.ListenerWrapper)
471 + if !ok {
472 + return nil, fmt.Errorf("config for a listener wrapper did not provide a value that implements caddy.ListenerWrapper")
473 + }
474 + jsonListenerWrapper := caddyconfig.JSONModuleObject(
475 + listenerWrapper,
476 + "wrapper",
477 + listenerWrapper.(caddy.Module).CaddyModule().ID.Name(),
478 + warnings)
479 + srv.ListenerWrappersRaw = append(srv.ListenerWrappersRaw, jsonListenerWrapper)
480 + }
481 +
482 // set up each handler directive, making sure to honor directive order
483 dirRoutes := sblock.pile["route"]
484 siteSubroute, err := buildSubroute(dirRoutes, groupCounter)