@@ -5,11 +5,41 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8- ## [ 2.3.0] - 2025-??-??
9-
10- - Fix [ #511 ] ( https://github.com/Neoteroi/BlackSheep/issues/511 ) . Add support for
11- inheriting endpoints from parent controller classes, when subclassing controllers.
12- An important feature that was missing so far in the web framework. Example:
8+ ## [ 2.3.0] - 2025-05-10 :sun_behind_small_cloud :
9+
10+ > [ !IMPORTANT]
11+ >
12+ > This release, like the previous one, includes some breaking changes to the
13+ > public code API of certain classes, hence the bump in version from ` 2.2.0 ` to
14+ > ` 2.3.0 ` . The breaking changes aim to improve the user experience (UX) when
15+ > using ` Controllers ` and registering routes. In particular, they address
16+ > issues [ #511 ] ( https://github.com/Neoteroi/BlackSheep/issues/511 ) and
17+ > [ #540 ] ( https://github.com/Neoteroi/BlackSheep/issues/540 ) .The scope of the
18+ > breaking changes is relatively minor, as they affect built-in features that
19+ > are * likely* not commonly modified: removes the ` prepare_controllers ` and the
20+ > ` get_controller_handler_pattern ` from the ` Application ` class, transferring
21+ > them to a dedicated ` ControllersManager ` class. Additionally, the ` Router `
22+ > class has been refactored to work consistently for request handlers defined
23+ > as _ functions_ and those defined as _ Controllers' methods_ .
24+ >
25+ > The _ Router_ now allows registering all request handlers without evaluating
26+ > them immediately, postponing duplicate checks, and introduces an
27+ > ` apply_routes ` method to make routes effective upon application startup.
28+ > This change is necessary to support using the same functions for both
29+ > _ functions_ and _ methods_ , addressing issue [ #540 ] ( https://github.com/Neoteroi/BlackSheep/issues/540 ) ,
30+ > improving UX, and eliminating potential confusion caused by having two
31+ > sets of decorators (` get, post, put, etc. ` ) that behave differently. While
32+ > the two sets of decorators are still maintained to minimize the impact of
33+ > breaking changes, the framework now supports using them interchangeably.
34+ >
35+ > While breaking changes may cause inconvenience for some users, I believe the
36+ > new features in this release represent a significant step forward.
37+ > Now Controllers support routes inheritance! This is an important feature that
38+ > was missing so far in the web framework.
39+
40+ - Fix [ #511 ] ( https://github.com/Neoteroi/BlackSheep/issues/511 ) . Add support
41+ for inheriting endpoints from parent controller classes, when subclassing
42+ controllers. Example:
1343
1444``` python
1545from blacksheep import Application
@@ -29,13 +59,11 @@ class BaseController(Controller):
2959
3060class ControllerOne (BaseController ):
3161 route = " /one"
32-
3362 # /one/hello-world
3463
3564
3665class ControllerTwo (BaseController ):
3766 route = " /two"
38-
3967 # /two/hello-world
4068
4169 @get (" /specific-route" ) # /two/specific-route
@@ -44,13 +72,18 @@ class ControllerTwo(BaseController):
4472```
4573
4674- Add a new ` @abstract() ` decorator that can be applied to controller classes to skip
47- routes defined on them (only inherited classes will have the routes, prefixed by a
48- route).
75+ routes defined in them; so that only their subclasses will have the routes
76+ registered, prefixed by their own prefix).
77+ - ** BREAKING CHANGE** . Refactor the ` Application ` code to encapsulate in a
78+ dedicated class functions that prepare controllers' routes.
79+ - ** BREAKING CHANGE** . Refactor the ` Router ` class to handle consistently
80+ request handlers defined using _ functions_ and controllers' class _ methods_
81+ (refer to the note above for more information).
4982- Fix [ #498 ] ( https://github.com/Neoteroi/BlackSheep/issues/498 ) : Buffer reuse
5083 and race condition in ` client.IncomingContent.stream() ` , by @ohait .
51- - Fix [ #365 ] ( https://github.com/Neoteroi/BlackSheep/issues/365 ) , adding support for
52- Pydantic's ` @validate_call ` and ` @validate_arguments ` and other wrappers applied to
53- functions before they are configured as request handlers.
84+ - Fix [ #365 ] ( https://github.com/Neoteroi/BlackSheep/issues/365 ) , adding support
85+ for Pydantic's ` @validate_call ` and ` @validate_arguments ` and other wrappers
86+ applied to functions before they are configured as request handlers.
5487 Contribution by @aldem , who reported the issue and provided the solution.
5588- To better support ` @validate_call ` , configure automatically a default
5689 exception handler for ` pydantic.ValidationError ` when Pydantic is installed.
@@ -59,10 +92,21 @@ class ControllerTwo(BaseController):
5992- Fix [ #484 ] ( https://github.com/Neoteroi/BlackSheep/issues/484 ) . Improve the
6093 implementation of Server-Sent Events (SSE) to support sending data in any
6194 shape, and not only as JSON. Add a ` TextServerSentEvent ` class to send plain
62- text to the client.
95+ text to the client (this still escapes new lines!) .
6396- Modify the ` is_stopping ` function to emit a warning instead of raising a
6497 ` RuntimeError ` if the env variable ` APP_SIGNAL_HANDLER ` is not set to a
6598 truthy value.
99+ - Improve the error message of the ` RouteDuplicate ` class.
100+ - Fix [ #38 ] ( https://github.com/Neoteroi/BlackSheep-Docs/issues/38 ) for notations that
101+ are available since Python 3.9 (e.g. ` list[str] ` , ` set[str] ` , ` tuple[str] ` ).
102+ - Fix [ a regression] ( https://github.com/Neoteroi/BlackSheep/issues/538#issuecomment-2867564293 )
103+ introduced in ` 2.2.0 ` that would prevent custom ` HTTPException ` handlers from
104+ being used when the user configured a catch-all ` Exception ` handler
105+ (** this practice is not recommended; let the framework handle unhandled exceptions
106+ using ` InternalServerError ` exception handler** ).
107+ - Add a ` Conflict ` ` HTTPException ` to ` blacksheep.exceptions ` for ` 409 `
108+ [ response code] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/409 ) .
109+ - Improve the test code to make it less verbose.
66110
67111## [ 2.2.0] - 2025-04-28 🎉
68112
0 commit comments