Local DOI resolver?

With LaTeX, Bibtex and the hyperref package, it is quite easy to spit out bibliographies with links described by the Digital Object Identifier (DOI). Clicking these links takes you to the journals abstract page for the work in question, where you can usually directly download PDFs (due to the everpresent IP-zone based royalty schemes most university have set up). This is nice and all, but what should really happen is of course that you local pdf copy should be accessed: Accessible even without net, containing your personal notes, etc.

So how to catch the links? Although DOI is actually a URN (i.e. DOI: is a valid link) (well almost – according to this page, it is actually not registered), this seems completely un-implemented (you can get a Firefox plugin if you like), so most places resort to making DOI links go to the HTTP resolver at http://dx.doi.org. This means that in addition to writing a DOI handler (that looks for local copies and otherwise passes of to doi.org), I need to set up something that catches requests to http://dx.doi.org and maps those to the DOI handler. Hmm