The REST api is exposed using /api/v1, but that is rewritten to hit /api/v1/app.pl/api/v1 (app.pl being a Mojolicious::Command wrapper for running in Mojolicious under Plack). The problem is that Mojolicious then creates URLs containing that unneeded /api/v1/app.pl prefix. We should strip that out. To reproduce: - Point your browser to http://your_host_name/api/v1/ (don't forget about the trailing slash) => FAIL: Notice basePath: "/api/v1/app.pl/api/v1"
Created attachment 71239 [details] [review] Bug 20134: Remove /api/v1/app.pl from the generated URLs This patch removes the /api/v1/app.pl prefix from generated baseUrl. It has the consequence of hardcoding / as the base path for the API. This is ok because we don't currently support mounting Koha pieces in different than hardcoded paths (/cgi-bin/koha?), but certainly worth mentioning because this will need to depend on a syspref or config entry when someone chages this behviour. To test: - On master, point your browser to: http://kohadev.mydnsname.org:8080/api/v1/ => FAIL: basePath looks like /api/v1/app.pl/api/v1 - Apply this patch - Restart memcached and plack: $ restart_all or $ sudo systemctl restart memcached && sudo systemctl restart koha-common - Reload http://kohadev.mydnsname.org:8080/api/v1/ => SUCCESS: basePath is /api/v1 - Sign off :-D
I just discovered that I can go to http://kohadev.mydnsname.org:8080/api/v1.html to have the API spec in a readable format, which is nice :) And also that it doesn't work in CGI mode (http://kohadev.mydnsname.org/api/v1/.json works curiously, but not the html version ; etc/koha-httpd.conf probably needs some changes) Anyway, the patch works, so, sign-off coming soon ;)
Created attachment 71244 [details] [review] Bug 20134: Remove /api/v1/app.pl from the generated URLs This patch removes the /api/v1/app.pl prefix from generated baseUrl. It has the consequence of hardcoding / as the base path for the API. This is ok because we don't currently support mounting Koha pieces in different than hardcoded paths (/cgi-bin/koha?), but certainly worth mentioning because this will need to depend on a syspref or config entry when someone chages this behviour. To test: - On master, point your browser to: http://kohadev.mydnsname.org:8080/api/v1/ => FAIL: basePath looks like /api/v1/app.pl/api/v1 - Apply this patch - Restart memcached and plack: $ restart_all or $ sudo systemctl restart memcached && sudo systemctl restart koha-common - Reload http://kohadev.mydnsname.org:8080/api/v1/ => SUCCESS: basePath is /api/v1 - Sign off :-D Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
I get a not found trying to access: http://localhost:8080/api/v1 Am I missing something?
(In reply to Katrin Fischer from comment #4) > I get a not found trying to access: > http://localhost:8080/api/v1 > > Am I missing something? Working for me: http://localhost:8080/api/v1/
Josef, feel free to pass QA then - I think my devbox might just be a bit outdated.
(In reply to Katrin Fischer from comment #4) > I get a not found trying to access: > http://localhost:8080/api/v1 > > Am I missing something? Yes, the trailing slash.
Hah! Will try again in the evening.
... and it sure was the trailing slash!
Created attachment 71325 [details] [review] Bug 20134: Remove /api/v1/app.pl from the generated URLs This patch removes the /api/v1/app.pl prefix from generated baseUrl. It has the consequence of hardcoding / as the base path for the API. This is ok because we don't currently support mounting Koha pieces in different than hardcoded paths (/cgi-bin/koha?), but certainly worth mentioning because this will need to depend on a syspref or config entry when someone chages this behviour. To test: - On master, point your browser to: http://kohadev.mydnsname.org:8080/api/v1/ => FAIL: basePath looks like /api/v1/app.pl/api/v1 - Apply this patch - Restart memcached and plack: $ restart_all or $ sudo systemctl restart memcached && sudo systemctl restart koha-common - Reload http://kohadev.mydnsname.org:8080/api/v1/ => SUCCESS: basePath is /api/v1 - Sign off :-D Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Pushed to master for 18.05, thanks to everybody involved!
Awesome work all, pushed to stable for 17.11.03