Getting the selected backend after acls were evaluated

Hello

Some of my services rely on data that is usually encrypted and needs to be decrypted before the service can be accessed. My haproxy.cfg looks similar to this:

frontend main
	mode http
	bind *:80
	
	use_backend w1 if { path_beg -i /w1 }
	use_backend w2 if { path_beg -i /w2 }
	use_backend enc_w3 if { path_beg -i /w3 }
	use_backend w4 if { path_beg -i /w4 }
	
	# At this point I would like to hook a lua script calling a bash script and start the decryption process. User should be redirected to a landing/waiting page when a backend was selected that needs processing before 
	
backend w1
	server w1 ...

...

backend enc_w3
	server enc_w3 ...

Is this generally possible with haproxy? I think I solved every problem/detail apart from getting the selected backend. Thanks for your thoughts/time