Where should I add a handler to the route?

I want to add a processing function to the route that creates the user, get the value and then request the third-party API, and insert it into the database after processing.