registerMiddleware
Registers a new middleware instance.
If the provided middleware is already registered, this function does nothing. Otherwise, it detaches the currently active middleware (if any), updates the state to the new middleware, and attaches it to the current context if available.
Parameters
middleware
The middleware instance to register.