Deny access to path by regex?

Is there a built in way to configure a middleware that blocks access to certain paths based on a regular expression?

Case in point I want to block any access to paths containing a /.git/ in the path.

Simplest way I found is using the blockpath plugin:

Create another router with Host() && PathRegex() (doc) and use noop@internal service.