Bug 17030: Make REST api available on packages with plack enabled
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 4 Aug 2016 14:47:16 +0000 (11:47 -0300)
committerFrédéric Demians <f.demians@tamil.fr>
Mon, 8 Aug 2016 14:46:13 +0000 (16:46 +0200)
commit222496f04550dd4819456d8302ef211897e2d8a7
tree31d06b2970326b0f54eddc89e878c5cfbbbf6f43
parent0f706677bd4016816f903c740a8ac0e361aa9f78
Bug 17030: Make REST api available on packages with plack enabled

This patch is the starting point for making the REST api available
on Plack.

What it does:
- It creates the /api/v1/app.pl mount point in plack.psgi
- It enables the ProxyPass and ProxyPassReverse directives so it
  is reached through Plack.
- It sets rewrite rules so we can use the 'pretty' urls (i.e.
  /api/v1/patrons instead of /api/v1/app.pl/api/v1/patrons).

To test:
- Grab the following files, and put them in /etc/koha (overwrite the existing ones)
  debian/templates/apache-shared-intranet-plack.conf
  debian/templates/apache-shared-opac-plack.conf
- Tweak your /etc/koha/sites/kohadev/plack.psgi file so the API-related stuff
  is present on your file.
- Make sure Plack is enabled for the instance:
  $ sudo koha-plack --enable kohadev
  $ sudo koha-plack --restart kohadev
  $ sudo service apache2 restart
- Follow the previous patch test plan, but use this URLs (no pretty URL):

  http://localhost:8080/api/v1/app.pl/api/v1/patrons/50
  http://localhost:8081/api/v1/app.pl/api/v1/patrons/50
=> SUCCESS: You get a JSON response from the API [1]
- Not use this URLs:
  http://localhost:8080/api/v1/patrons/50
  http://localhost:8081/api/v1/patrons/50
=> SUCCESS: You get a JSON response from the API [1]
- Sign off :-D

[1] this patch made a bug visible (the session is lost when accessing the API through
Plack) but it shouldn't prevent its inclusion because the API right now is not even available
as default for developers to test or fix it.

Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit e4bb70a447c7a6ea5e7498250adbe0e152259974)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
debian/templates/apache-shared-intranet-plack.conf
debian/templates/apache-shared-opac-plack.conf
debian/templates/plack.psgi