ClusterHQ / powerstrip

Powerstrip: A tool for prototyping Docker extensions
https://clusterhq.com/
Apache License 2.0
302 stars 32 forks source link

protocol v2: Type not in json #41

Open progrium opened 9 years ago

progrium commented 9 years ago

I think we agreed via email it would be good to have PowerstripProtocolVersion in headers since if we change the structure or content type, we'd lose a reliable way to check the version. We'd have to version how we version! Kidding. For a similar but different reason, I think Type should not be in JSON either.

When you're used to Python/Ruby you don't think about this as much, but it really sucks to have data structures define what they inside themselves. Imagine Content-Type being part of the body. What!? How would you handle that?

Using Go makes this obvious since we have to parse the payload twice to determine which type of struct to use when unmarshaling: https://github.com/ClusterHQ/powerstrip/blob/golang/protocol_test.go#L15

lukemarsden commented 9 years ago

I totally get this. But let's discuss whether we want to keep the JSON format or not in https://github.com/ClusterHQ/powerstrip/issues/44 before we decide to start moving things into HTTP headers.

robhaswell commented 9 years ago

@lukemarsden I disagree, I think we can continue to consider this without making a decision on #44.

I'm in favour of this proposal. We should be able to determine the schema of the body just from the header, and this includes both the version AND whether or not is is a pre/post hook.

:+1: