Big restructure to REST route logic. See desc.

REST routes now check to see if the debug_rest variable is enabled. When
debug_rest is enabled, the signature of the client is ignored.
Otherwise, the server will respond with an HTTP 400 error.