webpipes / spec

Webpipes is a work-in-progress proposal for linking together web services. Essentially, you can think of webpipes as tiny web services modeled after the UNIX philosophy: small utilities that do one thing, and do it well.
https://webpipes.org/
21 stars 2 forks source link

Proposal for POST requests on /block-endpoint #1

Open jpf opened 11 years ago

jpf commented 11 years ago

The spec defines expected behavior:

>>> POST /block-endpoint
>>> Content-Type: application/json
>>> …more headers…
>>> {"input": {"foo": "Value for foo input", "bar": "Value for bar input"}}

<<< 200 OK
<<< Content-Type: application/json
<<< …more headers…
<<< {"output": [{"baz": "Value for baz output", "qux": "Value for qux input"}]}

However, for people who are manually exploring the API (with curl, for example) I propose that we define how webpipe endpoints would respond to unexpected input:

>>> POST /block-endpoint
>>> Content-Type: application/x-www-form-urlencoded
>>> …more headers…
>>> test=true

<<< 400 BAD REQUEST
<<< Content-Type: application/json
<<< …more headers…
<<< {"output": [{"error": "webpipe input expected", "more-details": "http://example.com/error/input-expected"}]}
progrium commented 11 years ago

Hmm. Well self-description is part of the protocol. Right now that would be with the OPTIONS verb. I'm torn though because if it where a different URL, I could imagine referencing it in an error to a bad request, but it seems like it should be clear to use the OPTIONS verb.

jpf commented 11 years ago

I'm not tied to a particular implementation. Just proposing a gentle nudge of some sort to developers who aren't used to OPTIONS yet.

jpf commented 11 years ago

As an aside, how does one make an OPTIONS request with curl(1)?

progrium commented 11 years ago

True. Command line tools will either tell you how to use help or display it in place when you use it wrong. I think that's a good pattern.

On Wed, Nov 28, 2012 at 2:28 PM, Joël Franusic notifications@github.comwrote:

I'm not tied to a particular implementation. Just proposing a gentle nudge of some sort to developers who aren't used to OPTIONS yet.

— Reply to this email directly or view it on GitHubhttps://github.com/webpipes/spec/issues/1#issuecomment-10825969.

Jeff Lindsay http://progrium.com

progrium commented 11 years ago

-X/--request

curl -X OPTIONS http://example.com

On Wed, Nov 28, 2012 at 2:29 PM, Joël Franusic notifications@github.comwrote:

As an aside, how does one make an OPTIONS request with curl(1)?

— Reply to this email directly or view it on GitHubhttps://github.com/webpipes/spec/issues/1#issuecomment-10826029.

Jeff Lindsay http://progrium.com