scripting / Scripting-News

I'm starting to use GitHub for work on my blog. Why not? It's got good communication and collaboration tools. Why not hook it up to a blog?
121 stars 10 forks source link

Prior art search: URLs for CLI interface to PagePark on local machine #173

Open scripting opened 4 years ago

scripting commented 4 years ago

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.

scripting commented 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. :-)

kimhornung commented 4 years ago

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.

mterenzio commented 4 years ago

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/

mterenzio commented 4 years ago

Or listen on different port for these calls. Not sure if that is super simple or a pain here

scripting commented 4 years ago

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.