Skip to content

Improve binding logic - #597

Merged
RobertoPrevato merged 11 commits into
mainfrom
fix/588
Sep 27, 2025
Merged

Improve binding logic#597
RobertoPrevato merged 11 commits into
mainfrom
fix/588

Conversation

@RobertoPrevato

Copy link
Copy Markdown
Member
  • Improve the code responsible of mapping input request parameters into
    instances of desired types. Change the inner workings of
    blacksheep.server.bindings to make the code more configurable and easier to
    maintain.
  • Add support for StrEnum and IntEnum to binders for request handlers'
    parameters. See #588.
    Enums can be mapped by key and by value. The class that matches StrEnum
    make case sensitive checks; override the __missing__ method of your
    user-defined enums to support case insensitive checks; or define a custom
    StrEnumConverter class.
  • Add support for Literal to binders for request handlers'
    parameters. See #588.
    String literals are case sensitive by default.
  • Minor breaking change. Remove the dependency on python-dateutil
    (#544), which was always
    used to parse input datetime parameters. The datetime parsing logic is
    replaced 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 more
    performant for such formats. The new code API offers a simple way to keep
    using python-dateutil for those who desire doing so.
  • 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.

- 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
RobertoPrevato merged commit a5a2ac3 into main Sep 27, 2025
13 checks passed
@RobertoPrevato
RobertoPrevato deleted the fix/588 branch September 27, 2025 19:29
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

Successfully merging this pull request may close these issues.

1 participant