register middleware