Move the code for /rest/libraries a bit
Create a /rest/:action route, with getbook and listbooks as actions

This route makes sure security is taken care of in a uniform way.