Skip to content
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

Is there a way to use this with a different webserver? #133

Open
iffy opened this issue Dec 20, 2022 · 3 comments
Open

Is there a way to use this with a different webserver? #133

iffy opened this issue Dec 20, 2022 · 3 comments

Comments

@iffy
Copy link

iffy commented Dec 20, 2022

I'd like to use websock but just ran into this line, which forbids any HTTP method except GET:

if header.meth notin {MethodGet}:

I'm guessing that means you'd like the websock HTTP server to remain a WebSockets-only server? If that's the case, are there any examples of using websock within a different HTTP web framework (jester? chronos?)? Or would you accept a PR that allows for POST requests?

@jangko
Copy link
Contributor

jangko commented Dec 21, 2022

I never tested it before, maybe need some tweaks. handleRequest is actually not too dependent on a particular HTTP server.
The only thing you need to make sure is you can provide HttpRequest object, and the HttpRequest itself is a composition of chronos components.

proc handleRequest*(

@arnetheduck
Copy link
Member

I think in general it would be good to enable the possibility of multiple "protocols" on a single "http" port - ie we need this for nimbus as well since we want websockets and "regular" json-rpc to coexist without having to run two http servers (and ideally metrics and rest also) - any step towards the the possibility of mixing and matching websockets, normal http requests and also server side event streams would be good to have in general, though this would require the http server part to become extensible / pluggable - not sure what's possible today cc @cheatfate

@dryajov
Copy link
Member

dryajov commented Mar 2, 2023

It shouldn't be too hard to make the HTTP part pluggable, we can replace the HttpRequest object that handleRequest expects by either a generic that has the expected shape or a dynamically dispatched interface (the former is preferable)... The request object should allow reading/writing headers and responses. So, it would be possible to for example wrap a raw chronos HttpRequest object and use that instead of the default websock HttpRequest. Full HTTP support, was beyond the scope of the library at the time it was implemented and use cases like this were supposed to be handled by a reverse proxy or similar, still making the HTTP part pluggable is easy and should most likely be supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants