placestrio.blogg.se

Base64 encoding explanation
Base64 encoding explanation




base64 encoding explanation

Even though the cursor is supposed to be a perfectly opaque value for a client, in this case it's not because of the Base64 type inconsistency: In request query parameter, the Base64 type is decoded as URL encoded base64 string. The nextCursor field is then returned as a JSON field. The request cursor parameter is a query parameter of a GET HTTP call.

base64 encoding explanation

I use type: string, format: byte in my swagger specification (I use go-swagger v0.27.0) for both request parameter and response field.

#Base64 encoding explanation code#

I have observed this issue in my code which implements cursor-based pagination algorithm. I was able to track that this change has been implemented in #57 as a reaction to #56, but I was not able to find any explanation justifying this inconsistent behaviour. This behaviour is inconsistent both with the type doc-comment, but it's also inconsistent behaviour of the type itself, as some methods use different encoding than others. Namely JSON and BSON serialization and deserialization and also database interfaces sql.Scanner and driver.Valuer all of those use standard base64 encoding and not URL encoding as the doc-comment states. But it's definitely not true for the rest of interfaces implemented. It's true that the type uses URL encoding to implement TextMarshaler and TextUnmarshaler interfaces. Unfortunately the doc-comment is just partially true. Base64 represents a base64 encoded string, using URLEncoding alphabet






Base64 encoding explanation