-
Notifications
You must be signed in to change notification settings - Fork 126
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
Split WebSocket and HTTP server - Breaking Change #230
base: master
Are you sure you want to change the base?
Conversation
Sorry in advance for the long post, but wanna address some points in detail. First things first: have you tried using the Regarding suggested approach
I love it, but I would like to still offer devs the possibility to run this lib easily and standalone. I know creating an http server is only a few LOCs, but the UX of just having to invoke That being said we could offer such a standalone version with an additional config parameter/function 🤔 This would also enable "backwards-compatibility".
True, check my point above.
Same as above. Also tbf the entire TLS support was never meant to be used in large-scale systems (reverse proxies would take care of it) but rather for rapid prototyping.
Thank you, definitely a keeper 👍
See my answer to the first point. Assuming we offer both a standalone start option and your suggested approach, we would still need a simple HTTP server that supports pattern handling ( |
Great answer, thank you! Sounds like you're ok with the goal/approach in general but would like to keep the ease of use for prototyping? If that's correct we could create an example application (good Go practice) or provide some wrapper methods. Full compatibility would not be an option though. One thing that would get los- or rather no longer needed- might be testing of the wrapper methods, at least not to the extend done today.
I didn't actually and it feels kinda backwards having to do this. Our application evcc.io starts an ocpp server only if configured and would then always need to do that just to serve it's UI. That's a bad dependency to have.
Good point, agreed. I wouldn't care if mux is a dependency of this library tbo, just not having to use it would be great. |
Yes, that would be my wish.
Wrapper methods could indeed automatically create an HTTP router with all the existing logic and keep the dev experience basically identical. Updating the existing examples would then be a 1-liner. Happy to help with this part (although I currently have limited time to spare).
Makes sense. The suggested improvements are definitely welcome since everything remains stdlib-compatible. |
Just fyi, since this will be a breaking change, I'd love to make it into a dedicated release when it's ready. |
Fix #176
I've attempted to multiplex OCPP and HTTP traffic on a single port. This is currently not possible since the HTTP handler construction is part of the
websocket.Server
.This PR removes all
http.Server
setup:websocket.WsServer
interface is modified to return anhttp.HandlerFunc
to make it pluggable for anyhttp.Handler
net.Listener
concern and is no longer part of the OCPP libraryTODO
websocket
interface descriptionswebsocket
andnetwork
tests@lorenzodonini is this something you would consider? Waiting for your comments before spending further efforts.