Middleware for services.