-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support for short GUIDs #3
Comments
Hi Daniel, I am not overly familiar with the short Guid, is it just a base64 string representation that is parsed to a 128bit GUID? The most tedious part will be making decision tree of wheather base16 or base64 string so that is it still virtually same performance... I would prefer to use a spare format char ( Do you want to have a bash at a PR or is it bit tough to reason in which case i can try put something in soon? |
Giraffe's default router uses Your understanding is correct; it's the GUID as a base64 string. I did some digging over the weekend, and the algorithm I was seeing was that 4 6-bit characters become 3 bytes in the output. I'm sure calling I would be up for attempting a PR, especially since the output could be easily tested by calling the Giraffe methods to ensure they were equivalent. I'll fork and work on it, probably starting this evening (US Central). |
Cool, maybe for now, don't worry too much on the perf, base 64 is quite messy trying to map to the 16 bytes needed for the guid, 64 char will map to 6bits, 4 chars making 3 bytes, but they usually map in twos / fours in the layout so there may be a lot of partial shift logic that would make it a night mare... if you think you can do it by all means but I realise that it's way more involved then 32 * hex chars. and probably not worth it if you don't have a known perf problem anyway. |
I attempted to use a short GUID with the token router, and it didn't like it. I checked, and sure enough, this one doesn't support it - yet. Would you entertain a PR for it?
My thought was to check in the GUID parsing logic to see if the captured length was 22 characters, and if so, run it through
ShortGuid.toGuid
. It may not be the most efficient way to do it (I imagine there's a reason it doesn't useGuid.TryParse
on the chunk of captured data), but it would provide support for the format.It might not be too tough to parse through it in chunks of 4 characters, and grab the bits from there via a lookup table. The lookup table part makes me wonder how efficiently it could be done. I'm definitely not too strong with bit-shifting.
Anyway, let me know. I don't know that I could turn it really quick, but I think it wouldn't take too long.
The text was updated successfully, but these errors were encountered: