add option middlewares to customize middleware stack
fix specs
fix jruby
refactor: remove conditional