add a hook for the beforeRequest event.