Improve binding logic - #597
Merged
Merged
Conversation
- Fix erroneous assumption when parsing a request body declared as `bytes`. When the declared requested input body is `bytes`, the framework has been corrected to not require URL-safe base64 encoded data, and to read the input body as-is. - Add support for defining `convert` functions in custom `BoundValue` classes that are used to convert Python objects from parsed JSON into more specific classes. - Correct bug that prevented request body input to be mapped properly to a `list` using the default logic.
RobertoPrevato
force-pushed
the
fix/588
branch
from
September 27, 2025 13:09
421daff to
8fa44d4
Compare
This was referenced Sep 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
instances of desired types. Change the inner workings of
blacksheep.server.bindingsto make the code more configurable and easier tomaintain.
StrEnumandIntEnumto binders for request handlers'parameters. See #588.
Enums can be mapped by key and by value. The class that matches
StrEnummake case sensitive checks; override the
__missing__method of youruser-defined enums to support case insensitive checks; or define a custom
StrEnumConverterclass.Literalto binders for request handlers'parameters. See #588.
String literals are case sensitive by default.
python-dateutil(#544), which was always
used to parse input
datetimeparameters. The datetime parsing logic isreplaced with a function that only supports the most common ISO formats:
%Y-%m-%dT%H:%M:%S.%f,%Y-%m-%dT%H:%M:%S,%Y-%m-%d, and is much moreperformant for such formats. The new code API offers a simple way to keep
using
python-dateutilfor those who desire doing so.bytes.When the declared requested input body is
bytes, the framework has beencorrected to not require URL-safe base64 encoded data, and to read the input
body as-is.
convertfunctions in customBoundValueclassesthat are used to convert Python objects from parsed JSON into more specific
classes.
a
listusing the default logic.