define decoratable function. like connect middleware.