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

Context seems like an innapropriate label #941

Open
arceusawsom1 opened this issue Nov 14, 2023 · 0 comments
Open

Context seems like an innapropriate label #941

arceusawsom1 opened this issue Nov 14, 2023 · 0 comments

Comments

@arceusawsom1
Copy link

This is kind of mentioned in #654 ,

With most other web technologies, context is used to add a prefix to everything relating to a certain library, this can be helpful for seperation of concerns as well as complying with reverse proxies, as well as generally being more portable.

Not only does the context in netty/socket.io not prefix everything (namespaces at the very least), but it changes the endpoint for the handshake.

I propose that we move the handshake endpoint setting into a new field (handshakePath, as an example), then change context to apply to everything in the library (including the new handshake path).

Example:

// Create the config
Configuration config = new Configuration();
// Setting values
config.setHostname("someHostname");
config.setPort(5001);
config.setContext("/api/socket");
config.setHanshake("/handshake");
// Creating the server
SocketIoServer server = new SocketIoServer(config);
// Add the namespace
SocketIoNamespace namespace = server.addNamespace("/chat");

The behavior should be as follows:
Handshake Url:
http://someHostname:5001/api/socket/handshake
To join the chat mainspace:
ws://someHostname:5001/api/socket/chat

A major benefit of this is if you ever decide to relocate your service, or put it behind a reverse proxy, you would only need to change the context path, the default value for the context path could be an empty string.

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

1 participant