gliderlabs / cmd

Other
28 stars 4 forks source link

Allow parsing k/v GET or POST params? #139

Closed chiefy closed 7 years ago

chiefy commented 7 years ago

I was thinking of writing a blog post on how to use cmd.io to create a simple Slack slash command. The issue became that Slack dictates the structure of the parameters it sends as k/v GET query or POST parameters.

I started toying with an idea to convert the query string to a parsed JSON string representation. I got a PoC working on this branch.

The below cmd is just

#!cmd alpine jq bash
#!/bin/bash
jq -n "${1}"

output:

❯ curl "http://863814a0-7f1d-4b40-86b2-19cd888da8d3@localhost:8080/run/chiefy/yoda?test=awesome+query+params&num_params=3&this=isjson"
{
  "num_params": "3",
  "test": "awesome query params",
  "this": "isjson"
}

Thoughts?

progrium commented 7 years ago

I think if we're going to expose HTTP request data to the shell we should do it using the existing standard of CGI which was invented for this purpose! :D

progrium commented 7 years ago

Oh but also great idea and I'd love that blog post.

chiefy commented 7 years ago

@progrium didn't even think of that.

progrium commented 7 years ago

You were on the right path though! Do you want to open an issue to implement supporting CGI?

chiefy commented 7 years ago

@progrium yes, I started messing around w/ this last night. I will open a new issue.