-
Notifications
You must be signed in to change notification settings - Fork 8
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
Non string_body requests #17
Comments
If we went the route of optionally passing a struct with overloaded call operator, instead of a function (as suggested above for setting up requests), it could also be used as the customisation point for #4. |
Yet another idea with this. It could allow easy integration with stuff like nlohmann::json too. The appropriate mimetypes could be set automatically, it would use |
This is certainly a step in the right direction. All of the good stuff that is on the ToDo list for this library. I am very glad that you dropped by :p Do you already have a proof-of-concept of this? |
Not really, I've got early stage stuff in feat-custom-requests but it doesn't even compile yet and the commit history is a mess. Should have some time to work on it today/this evening though |
So I'm most of the way there now with http. Wondering how to do the websocket side of things. Honestly I quite like the idea of scraping the current interface and going with a concept that has Interested in your thoughts on this. Especially on how we can do the buffers since I have very little experience with the websocket side of beast. |
The current implementation of the websocket interface is far from what I'd like it to be. Unfortunately this was created under some pressure of an up-stream project that used I can't get into details right now regarding what I think would be best. However, having examined your contributions so far I think that you are very capable of providing a decent, well implemented solution design :p
There's a chance that I am misunderstanding. We should be able to re-use the various buffer implementations provided by |
Yeah I'm hoping to reuse the http body types from beast. But I'm not sure how that would actually work, and whether there are any issues there with assumptions about httpness (I'd guess not but like I said, not much experience :p). Also I feel like we should give the option of completely handing off to a customsation point (which gets given the socket), once the routing part is done, since this libraries job is routing and not websocket connection management (at least thats my understanding, if I'm wrong here please correct me). It would mean exposing quite a few implementation details of the library though so I'm not sure if its a good idea.
Thank you :) |
I might be completely wrong here (especially as I know HTTP better than WS too) but I don't think that that is possible - or wise to do. As far as I can tell, you just want to provide a binary stream (eg. byte buffers on each end - but then full duplex) and build the application on top of that.
In general I agree. For example, currently it seems difficult to close a websocket connection from the server side through an enpoint - exactly because of the reason you mentioned: The handler has no access to the connection itself and can only receive bytes and send bytes. This is actually an issue that one of my applications currently still has.
Nah, thank you ;-) |
This one is a good deal more complex than #13 imo. I've made a start on a possible implementation but its early stages and I might end up scrapping it. The main issue is that request bodies sometimes need some setup before being used (e.g.
file_body
needs opening before reading out). How that is actually exposed as a configuration point is one of the sticking points. My ideas on how this can be done outside of handling request setup:matches
for the endpoints can use this instead.request
in the same manner asresponse
handle
inendpoint_http
My current thoughts on the customisation of request setup:
Func
passed toadd
in router be optionally something which has a function which takes in a header and returns a variant of requests for it.add
for nice errors)connection
pass down a "generator" object instead of a requestconnection
since the stream type differs depending onDerived
endpoint_http
interface boundry the generator will be a variant based onconnection_plain
andconnection_tls
endpoint_http_regex
will have the pile ofstd::visit
s needed to sort out the message inhandle
endpoint_http_files
will be removed and implemented in terms ofendpoint_http_regex
inrouter
This should allow extensive customisation while keeping the interface simple for the usual use-case. I am concerned about the
Fields
option inheader
though, this currently does not leave room for that to be custom. Not sure if its in-scope for this library (I've never used them myself) but still worth mentioning. Also currently this does not include websockets which I think also need something similar. Possibly could use the same logic and just pass inrequest.body()
which would happen to bestd::string
by default.As I said at the beginning, I have an implementation along these lines (not quite complete) and I'd appreciate thoughts and feedback on this
The text was updated successfully, but these errors were encountered: