-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use enum instead of module for HTTP::WebSocket::CloseCodes #8981
Use enum instead of module for HTTP::WebSocket::CloseCodes #8981
Conversation
I think the problem with close codes is that there are lots of values. Is not the same situation as http status codes which are fixed by the rfc. I'm fine with using enums, if the option for using integers are still available. And if having those overloads does not prevent the autocasting feature to work on enums. Ref: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes |
@bcardiff It is available, and it has to be for http status codes to work as well, since there are many unassigned ones that could be used by the developers anyway. autocasting will obviously work only for the assigned ones. |
HTTP status codes are in fact extensible and not limited to registered ones (see https://tools.ietf.org/html/rfc2616#section-6.1.1). So it's one and the same thing.
I think a problem could be when we need to know all possible enum values at compile time. That's at least a possible scenario we should be aware of. But for now it is IMO fine to apply this change because the close codes are conceptually identical to HTTP status codes (registered set, but extensible). If the implementation of |
If there is a valid range like there is with |
6b9933e
to
d8dd32d
Compare
@Blacksmoke16 Good idea! I've force-pushed changes with the check. |
My idea is to force enums to have valid values, always. Right now Then, we could introduce an |
@asterite Sounds good, but please open an RFC issue about that, to not to stall this PR. |
Oh, of course. It's an idea, it's not necessary for this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this has any actual benefits...
19e3196
to
fecec34
Compare
Anything left to do in here? |
fecec34
to
30b7ea3
Compare
All comments addressed. |
Followup to #8975