I haven't found how to create middleware using internal web server in this article https://wiki.freepascal.org/fpWeb_Tutorial.
...
Could anyone point me where I can see any bits of this type of information?
What kind of middleware do you expect? The tutorial doesn't cover any of the fpWeb components you get in Lazarus Component Palette on purpose, because... I simply don't know how to work with them. And while the previous router have some injectable events, the more recent httproute router is much simpler and is exactly how you code it: It only links URIs to procedures, everything else should be made on top of that.
"Middleware" I'm talking about is a function where I can check something in a query and the decide what to do next with it accept or decline fo example.
The ordinary modern request track looks like: "/route1" -> middleware1_function(write query log)->middlware2_function(check user credentials) -> route1_function
in pascal fpweb framework it might look like this HTTPRouter.RegisterRoute('/route1', @middleware1_function(@middleware2_function(@route1)));
the design patter for this type is
decorator