mirror of
https://github.com/AdguardTeam/dnsproxy.git
synced 2026-10-12 02:01:26 +00:00
Merge in GO/dnsproxy from AGDNS-3523-add-ratelimit to master Squashed commit of the following: commit 5d51eb16af8de61f435bbf27513ed85d2687c64f Author: Dimitry Kolyshev <[email protected]> Date: Fri Feb 13 12:39:20 2026 +0700 handler: rename to middleware commit d281b05a28060b8f935ca677123fd970876cfeeb Author: Dimitry Kolyshev <[email protected]> Date: Fri Feb 13 12:35:08 2026 +0700 handler: migrate middleware commit bcb660f346bab2348303039adb3d4ec569ca23de Author: Dimitry Kolyshev <[email protected]> Date: Thu Feb 12 10:55:26 2026 +0700 proxy: imp code commit 53fc44ce671d0dd1d91724099ce5fca58e6ae39c Author: Dimitry Kolyshev <[email protected]> Date: Wed Feb 11 13:13:37 2026 +0700 ratelimit: imp tests commit ea3dd77460a2060f2e6fd1e2a41f28319e086f4b Author: Dimitry Kolyshev <[email protected]> Date: Wed Feb 11 12:56:26 2026 +0700 ratelimit: imp code commit 4460e5e0560396f1ed6ad29987cb40edc53c8402 Author: Dimitry Kolyshev <[email protected]> Date: Wed Feb 11 12:41:27 2026 +0700 all: imp commit 5411a3f5f7cf45de33d227ae3011e021d38bafb6 Author: Dimitry Kolyshev <[email protected]> Date: Tue Feb 10 10:20:16 2026 +0700 all: ratelimit package
27 lines
696 B
Go
27 lines
696 B
Go
package proxy
|
|
|
|
// Middleware is a common middleware interface.
|
|
type Middleware interface {
|
|
// Wrap returns a new handler that wraps the specified handler.
|
|
Wrap(handler Handler) (wrapped Handler)
|
|
}
|
|
|
|
// MiddlewareFunc is a function that implements the [Middleware] interface.
|
|
type MiddlewareFunc func(h Handler) (wrapped Handler)
|
|
|
|
// type check
|
|
var _ Middleware = MiddlewareFunc(nil)
|
|
|
|
// Wrap implements the [Middleware] interface for MiddlewareFunc.
|
|
func (f MiddlewareFunc) Wrap(h Handler) (wrapped Handler) {
|
|
return f(h)
|
|
}
|
|
|
|
// type check
|
|
var _ MiddlewareFunc = PassThrough
|
|
|
|
// PassThrough is a [MiddlewareFunc] that returns h as-is.
|
|
func PassThrough(h Handler) (wrapped Handler) {
|
|
return h
|
|
}
|