Open scripting opened 4 years ago
I know we had a solution for this in Frontier, I don't remember what it was specifically, I could look it up, but I remember not liking it. :-)
WordPress has a command line tool called WP-CLI (https://wp-cli.org/)
I'm not entirely sure if WP-CLI uses local URLs to communicate with the website/intance. I think they might be doing it in some other way.
But the WP eco system might be able to provide prior art in any case when it comes to the WP REST API where they use /wp-json as prefix. So a URL to get pages could for example be http://localhost/wp-json/v2/pages
Translating this to what you aim to do, you could decide on a prefix such as "pp-api".
So one way that your URL could look:
http://localhost/pp-api/v1/processes
Or
http://localhost/pp-api/v1/processes/list
Or
http://localhost/pp-api/v1/listRunningProcesses
Hope this might be helpful or point you in a useful direction.
It seems to me any system would have some reserved namespaces. Like in Unix, you can't have a root directory for yourself that is usr
I understand your reservations though (no pun intended)
In many early web systems, the tilde is used for user directories, e.g /~mterenzio/
You could do the opposite and not allow that character for names of local sites.
Making the url path something like /~exec/
Or listen on different port for these calls. Not sure if that is super simple or a pain here
Thanks for all the feedback, this is exactly what I was looking for.
I am doing what @mterenzio suggests -- using a different port. That keeps the namespaces nice and neat.
It's also a bit of a security thing. I only want these calls to work on the local machine.
I'm writing a command line tool to talk with PagePark, a web server running on the same machine.
It's natural to communicate over HTTP.
The question is what does the URL look like?
http://localhost/theInternalWebServer/listRunningProcesses
But that means the user can't have a local site named theInternalWebServer.
I guess some servers use a special character like a tilde for that? Or a $. Or what??
Looking for prior art.