Use pre initialized middleware

Try to use SessionsMiddleware. I plan to initialize a SessionsConfig first with some different cookie values and add a pre initialized SessionsMiddleware to MiddlewareConfig. But I found MiddlewareConfig.use() require the middleware to be thread-safe. So can I do that? looks like SessionsMiddleware is not thread-safe.

IIRC you can actually register the SessionsConfig as a service then leave SessionsMiddleware alone