-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request / response serialization to message #4
Comments
I think you should have a
Does it make any sense? |
I think we should have the HTTP body parsed for JSON, ecc.. otherwise doing crazy things will be hardish. However we should be able to disable that by turning a flag, or something similar. |
Makes sense! We can take a look at the content-type of the request and parse the body appropriately. The bridge function can accept a hash of options to disable this, which would just pass the request stream through. |
I'm also assuming that since graft-http will send the message right when the request comes in, the body will still be a stream, even if it is getting parsed as json, form data, etc. You would have to listen for |
@tamagokun I'm not sure on that. Otherwise a validation step might be tricky, and that's going to be parsed anyway for doing anything serious. |
Or if we want the body parsed, it will wait until the request is finished before sending the message? // parse: true
// graft sends message once request stream emits end. contents of body is string or object
graftHttp.use(service(), {parse: true}); |
I definitely think so. |
how much of this is going to be re-inventing connect/express though ? perhaps we should focus on adapting connect middleware to be used? |
Exactly. middleware micro-service. Something that could wrap up a connect middleware into a micro service that is consumable by graft. It would be great to create something that could achieve full interoperability with any http based middleware, but I haven't done any tests yet. All of the routing and parsing we are discussing could be handled by piping the request through to other graft-compatible middleware rather than using options. |
Converting requests to/from messages: https://github.com/GraftJS/graft-http/blob/draft/lib/request.js As I mentioned in #1, I need a better way to handle serializing the http request. Middleware and other things love to tack on properties to that and share them with other middleware, so I was imagining a black list of properties that we would throw away, and just keep the rest (plus a few convenience ones that aren't normally a part of http.IncomingMessage) |
This should be all set now. If message keys need to change at all, open a new issue. |
I wanted to start a new issue thread for figuring out how we will serialize requests and responses into graft messages.
I see 3 problems we need to solve:
Below is an ongoing draft of what these message blocks would look like:
I think 1 and 2 are already solved, we just need to decide on the message properties. For 3, I don't know how to best handle this. We would have a request stream, response stream, but also a return channel? Is there a way to merge these somehow?
@GraftJS/graft-http-committers
The text was updated successfully, but these errors were encountered: