httpipe
httpipe copied to clipboard
[proposal] HTTPipe.Conn.new/1 function
It would be nice if there was a function like this:
HTTPipe.Conn.new(%HTTPipe.Request{})
Example of how I am doing it now:
req = %HTTPipe.Request{
method: :post,
url: "/cloud/project/#{service_name}/user/#{user_id}/regeneratePassword"
}
Map.put(HTTPipe.Conn.new(), :request, req)
Would be nice if I could
%HTTPipe.Request{
method: :post,
url: "/cloud/project/#{service_name}/user/#{user_id}/regeneratePassword"
}
|> HTTPipe.Conn.new()
Just letting you know I definitely saw this, and I'm thinking about it. I've heard from someone else that perhaps the Conn
struct should be a reusable element for multiple reasons:
- The
Conn
could be responsible for maintaining a pool identifier - HTTP 2 will not have the same request/response cycle, so to make it version agnostic,
Conn
may just represent a generic connection and could operate with requests, responses, and with any ordering of the two.
About those items mentioned, I haven't thought about it too much.
- About the Conn struct being responsible for maintaining a pool identifier - i'm not sure this is a strong enough reason to make this a reusable element. Instead, the
Conn.t
could have apool
field which the user has to set. Then theHTTPConn.execute
function will be responsible for getting it executed by the correct pool. Does that make sense?
About HTTP2, I'd need to do more research before I could say for sure. Some modifications are probably need to HTTPipe.Conn.t
and Request.t
to make this work. But I'm still not convinced that it demands a reusable Conn.t
but I'd have to dwell on that.
- HTTP2 - could this be as simple as: (??)
- removing
http_version
fromHTTPipe.Request.t
and putting it intoHTTPipe.Conn.t
instead. - making the
request:
field into a list ofrequests
- making the
response:
field into a list ofresponses
- could make the
Conn.t
to:status_executed
only when all request responses returned
- removing
One thing I did think though was if genstage and streaming is being introduced, perhaps a rethink would be needed then or maybe a new type.
Another way might be to create abstractions at a higher level than HTTP.Conn.t
- say
%HTTP2{ conns: [%HTTP.Conn{},%HTTP.Conn{}], pool: _ }