HTTP 410 response for certain URLs

Hi,

I want to respond to a request for a certain URL with an HTTP 410 (Gone) code. The URL would be:
http://example.com/old-url.php?id=xxx

I do not know if there is another solution, but I’ve found in this community the following solution through Workers

So I would implement

addEventListener('fetch', event => {
  event.respondWith(fetchAndLog(event.request));
})

async function fetchAndLog(request) {
  if (/old-url.php?id=/g.test(request.url)) {
    return new Response("Page is gone.", {
      status: 410,
      statusText: "Gone"
    });
  }
  return fetch(request);
}

However, I do not know where to implement it. I’ve got a Pro Plan. If I go to ‘Workers & Pages > Create Worker’, I find a “Deploy Hello World script”. But I do not find how to edit it. Is as easy as clicking ‘Deploy’?