Centralized middleware

So I’m quite new too all this, but everything has been quite straightforward. But I am running into the same problem, again and again, what do i do with “centralized” middleware.

I would like to avoid having the same code multiple times. Lets say i have an auth and log function, i want to be able to call those functions from multiple services, is that possible? If so, how?