Add ported ring middleware
Finish port of middleware tests