drush-ops/drush — pull request #405 by kostajh (2014-01-23 19:14:14+00:00)
Title: Implement Drush web service API

This is another pass at the feature proposed in #291.

Based on @grugnog's comments, I decided to split this functionality into its own set of commands. There is now a `drush api-server` command (this listens for drush commands coming in at `http://localhost:8888` by default; host and port are configurable as are custom headers and allowable IPs); and a `drush api-request` command.

The user executes a command by issuing a GET request to, for example, `http://localhost:8888/@example.local core-status`. The request string (`$_SERVER['SCRIPT_NAME']`) is parsed in `api-prepend.php` and then a `shell_exec` call is made to `drush api-request @example.local core-status`. The `api-request` command then is responsible for setting the proper response code, headers, and JSON encoded output. All output is in JSON with this approach.

This is pretty simple and comes in at ~160 lines of code. That said there are some TODOs:

[ ] Add a docs entry for this functionality
[ ] Add support for HTTPServer
[ ] `drush_api_request()` could probably be split into a few functions.
[ ] Add tests

@weitzman please let me know what you think about this approach and what else needs to happen.

Kosta