So we should be checking the `$request` variable that would only be populated if the request was processed by `restful_menu_process_callback` (meaning API call). We could just add some kind of flag to it to allow testability.

Let me do a quick PR.