Custom routes return 404 error but correct content with HEAD request

Actually, I have no idea anymore. I now tried it again and it seems to work as expected. However, before reaching out here I did so as well and it didn’t work well with POST and HEAD requests.

What did lead me into the custom router direction was the fact that I couldn’t get it to work and Custom routes return 404 error but correct content with HEAD request - #2 by bvdputte assuming that the default router does only work with GET. The resources I found about routing POST requests lead me to the Toolkit API and custom routers as well. I’m glad I was proven wrong now, it seems to work as expected with this code snippet in site/config/config.php:

c:set( 'routes', array(
	array(
		'pattern' => 'archive/(:num)/mail',
		'method' => 'ALL',
		'action' => function( $no ) {
			if ( $issue = page( 'archive/' . $no ) ) {
				return new Response(
					snippet( 'copyMail', array( 'issue' => $issue ), true )
				);
			}
		}
	),
) );