gliderlabs / cmd

Other
28 stars 4 forks source link

Implement CGI #155

Closed chiefy closed 7 years ago

chiefy commented 7 years ago
progrium commented 7 years ago

Looking good. So no longer a work in progress?

chiefy commented 7 years ago

@progrium nope, squashed my commits and I think it's more-or-less ready. Need to add some docs though.

chiefy commented 7 years ago

FWIW - here's the results of a test I made

no args -----------------------------------

HOSTNAME=0e7dcb4ddcfc
SERVER_PORT=8080
HTTP_HOST=localhost
USER=e2eeea99-4a99-4496-969b-c93e466976e8
CMD_NAME=tester
REQUEST_URI=/run/chiefy/tester
SCRIPT_NAME=tester
PATH_INFO=/run/chiefy/tester
CMD_CHANNEL=dev
CMD_VERSION=dev
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/cmd
REMOTE_ADDR=
SHLVL=1
HOME=/root
SERVER_NAME=localhost
CONTENT_LENGTH=0
SERVER_SOFTWARE=cmd.io
QUERY_STRING=
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
CONTENT_TYPE=
REQUEST_METHOD=GET
_=/usr/bin/env

args:

-------------------------------------------

args query --------------------------------

HOSTNAME=269df05a85cb
SERVER_PORT=8080
HTTP_HOST=localhost
USER=e2eeea99-4a99-4496-969b-c93e466976e8
CMD_NAME=tester
REQUEST_URI=/run/chiefy/tester?args=hi%20how+yes%20asdf+some+other%20ones
SCRIPT_NAME=tester
PATH_INFO=/run/chiefy/tester
CMD_CHANNEL=dev
CMD_VERSION=dev
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/cmd
REMOTE_ADDR=
SHLVL=1
HOME=/root
SERVER_NAME=localhost
CONTENT_LENGTH=0
SERVER_SOFTWARE=cmd.io
QUERY_STRING=args=hi%20how+yes%20asdf+some+other%20ones
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
CONTENT_TYPE=
REQUEST_METHOD=GET
_=/usr/bin/env

args:
1-hi 2-how 3-yes 4-asdf 5-some 6-other 7-ones
-------------------------------------------

non-args query ----------------------------

HOSTNAME=5bced9581020
SERVER_PORT=8080
HTTP_HOST=localhost
USER=e2eeea99-4a99-4496-969b-c93e466976e8
CMD_NAME=tester
REQUEST_URI=/run/chiefy/tester?val=true&something=else&whatever=false+maybe
SCRIPT_NAME=tester
PATH_INFO=/run/chiefy/tester
CMD_CHANNEL=dev
CMD_VERSION=dev
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/cmd
REMOTE_ADDR=
SHLVL=1
HOME=/root
SERVER_NAME=localhost
CONTENT_LENGTH=0
SERVER_SOFTWARE=cmd.io
QUERY_STRING=val=true&something=else&whatever=false+maybe
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
CONTENT_TYPE=
REQUEST_METHOD=GET
_=/usr/bin/env

args:

-------------------------------------------
progrium commented 7 years ago

So cool! Now how do we get the request body into STDIN...

chiefy commented 7 years ago

@progrium you mean for POST requests? That's gonna be interesting.

progrium commented 7 years ago

Rebase and take a pass at docs ... maybe here: https://github.com/gliderlabs/cmd/blob/master/docs/api.md

chiefy commented 7 years ago

@progrium updated docs - feedback much appreciated. Not sure if you think simpler example is needed?

progrium commented 7 years ago

Cool, great idea for the docs. I think we can simplify the Bash for both the command (maybe just call env and echo "Args: $@") and creating the command (like just heredoc directly into SSH instead of making a var). And then the example running it could be collapsed from three into one that just describes args vs query params, etc. A more detailed walkthrough can be put together later.

progrium commented 7 years ago

@chiefy I'd like to merge this, can you make those changes to simplify the docs?

chiefy commented 7 years ago

@progrium updated PR.

progrium commented 7 years ago

I was expecting more to be cut. Try and edit it down more, otherwise we might not get this merged until one of us can take a stab at it.

chiefy commented 7 years ago

@progrium I axed one of the example outputs, and omitted some of the ENV output from the examples. Other than that I am not sure what you are looking for here?

progrium commented 7 years ago

No that helps a lot, thanks!

progrium commented 7 years ago

Btw, @chiefy are you able to merge this? I guess a recent change to perms means only certain people can merge to master... just want to make sure. I'll merge if not.