If the HTTP server supported a server scripting engine (JSP, PHP, a proprtietary language), you would've been able to do that, but there's no such support, and AFAIK, no plans to add such (beyond the pseudo server language for outputting hotspot variables that is).
You could always make the router redirect or dst-nat to a separate web server that controls it via the API protocol. The end user wouldn't know (or care about) the difference.
(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)