Add API doc for context middleware - see #337