Stdin middleware