summaryrefslogtreecommitdiff
path: root/listeners.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-03-15 21:26:17 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-03-15 21:26:17 -0600
commitf596fd77bb6880485d2bfc6b18a775b5572da260 (patch)
tree95039c9e11ac312efcc110c89a1e6ee6869c6d11 /listeners.go
parent0433f9d075452d78ac93c72bad37856dc1b5b6f7 (diff)
caddyhttp: Add support for listener wrapper modules
Wrapping listeners is useful for composing custom behavior related to accepting, closing, reading/writing connections (etc) below the application layer; for example, the PROXY protocol.
Diffstat (limited to 'listeners.go')
-rw-r--r--listeners.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/listeners.go b/listeners.go
index ae1873f..0bbee8a 100644
--- a/listeners.go
+++ b/listeners.go
@@ -386,6 +386,19 @@ func JoinNetworkAddress(network, host, port string) string {
return a
}
+// ListenerWrapper is a type that wraps a listener
+// so it can modify the input listener's methods.
+// Modules that implement this interface are found
+// in the caddy.listeners namespace. Usually, to
+// wrap a listener, you will define your own struct
+// type that embeds the input listener, then
+// implement your own methods that you want to wrap,
+// calling the underlying listener's methods where
+// appropriate.
+type ListenerWrapper interface {
+ WrapListener(net.Listener) net.Listener
+}
+
var (
listeners = make(map[string]*globalListener)
listenersMu sync.Mutex