A `Middleware` object wraps a handler function with associated metadata (`path`, `method`, `protocol`). Middleware functions have access to the request (`req`), response (`res`), and error (`err`) objects during the request–response cycle via the [`Router`].
An [`R6::R6Class`] generator for `Middleware` objects.
[Router], [Request], [Response], [Error]
pathPath this middleware matches, or `NULL` for all paths.
FUNHandler function executed when matched.
methodHTTP method to match (e.g., `"GET"`), or `NULL` for any.
protocolProtocol string: `"http"` or `"websocket"`.
new()Initialize middleware with handler, path, method, and protocol selection.
Middleware$new(FUN, path, method, websocket)