Skip to content

Commit 1af447f

Browse files
More corrections
1 parent 7d9d726 commit 1af447f

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

blacksheep/docs/client.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,14 @@ The `ClientSession` owns by default a connections pool, if none is specified for
7676
it. The connections pool is automatically disposed of when the client is exited,
7777
if it was created for the client.
7878

79-
!!! danger "Connection pooling is important"
80-
Avoid instantiating a new `ClientSession` at each web request, unless the
81-
same `ConnectionsPool` is reused among the instances. Instantiating a new
82-
`ClientSession` without reusing the same TCP connections pool has
83-
negative effects on the performance of the application.
79+
/// admonition | On the importance of connection pooling.
80+
81+
Avoid instantiating a new `ClientSession` at each web request, unless the
82+
same `ConnectionsPool` is reused among the instances. Instantiating a new
83+
`ClientSession` without reusing the same TCP connections pool has
84+
negative effects on the performance of the application.
85+
86+
///
8487

8588
It is recommended to instantiate a single instance of HTTP client and
8689
register it as a service of the application, using the `@app.lifespan` method:

blacksheep/docs/mounting.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Mounting applications
22

3-
The word "mounting" refers to the ability to plug ASGI applications into
4-
others, under specific routes. This enables reusing whole applications, or
5-
components, across web applications. This page describes:
3+
The term 'mounting' refers to the ability to integrate ASGI applications into others
4+
under specific routes. This enables reusing whole applications across web applications.
5+
This page covers:
66

7-
- [X] How to use the mount feature in BlackSheep.
8-
- [X] Details about mounting, and handling of application events.
7+
- [X] Using the mount feature.
8+
- [X] Details about mounting and handling of application events.
99
- [X] Mounting and OpenAPI Documentation.
1010
- [X] An example using [Piccolo Admin](https://github.com/piccolo-orm/piccolo_admin).
1111

@@ -50,18 +50,18 @@ In the example above, both `parent` and `child` are complete applications that
5050
can be started independently. If `child` is started alone, it replies to GET
5151
web requests at route "/" with the text "Hello, from the child app".
5252

53-
Since `parent` mounts `child` under the path "/sub", when `parent` is started, it
54-
delegates requests starting with `/sub/*` to the mounted application, therefore when the
55-
`parent` is started, a GET request to the route "/sub" produces the greetings message
56-
from `child`. A GET request to the route "/" instead is replied with the text "Hello,
57-
from the parent app".
53+
Since `parent` mounts `child` under the path '/sub', it delegates requests starting with
54+
`/sub/*` to the mounted application. As a result, when parent is started, a GET request
55+
to the route '/sub' produces the greeting message from `child`. A GET request to the
56+
route "/" instead is replied with the text "Hello, from the parent app".
5857

59-
!!! info
58+
///!!! info
6059
Try to create a file `server.py` like in the example above, and run the
6160
applications using `uvicorn`, to verify how they work in practice.
6261

6362
## Side effects of mounting
64-
Even though mounting can enable interesting scenarios, it comes at a price.
63+
64+
Although mounting enables interesting scenarios, it comes at a cost.
6565

6666
Applications that are supposed to be mounted by other applications need to be
6767
designed to be "mount-friendly", for example when they handle redirects or
@@ -115,9 +115,9 @@ app_b.mount("/a", app_a)
115115

116116
```
117117

118-
This won't produce the expected result in real-life scenarios! `app_a` in this
118+
This won't produce the expected result in real-life scenarios. `app_a` in this
119119
case redirects to the absolute path "/", therefore a path that is handled by
120-
`app_b`! In general, mounted apps will be defined in dedicated packages with
120+
`app_b`. In general, mounted apps will be defined in dedicated packages with
121121
no knowledge of the applications that mount them. To fix this scenario, it is
122122
necessary to use a relative path for redirection, like:
123123

@@ -128,6 +128,7 @@ def redirect_to_home():
128128
```
129129

130130
### Handling of application events
131+
131132
Applications often need to define actions that must happen when the application
132133
starts, and actions that must happen when the application stops.
133134

@@ -173,11 +174,8 @@ events.
173174
web framework used to implement it. The example above is correct when `child`
174175
is an instance of BlackSheep Application.
175176

176-
!!! danger "Note"
177-
`APP_MOUNT_AUTO_EVENTS` is not the default to not introduce breaking changes.
178-
This will be the default behavior in BlackSheep 2.x
179-
180177
## Mounting and OpenAPI Documentation
178+
181179
Since version `1.2.5`, BlackSheep supports generating OpenAPI Documentation
182180
for mounted BlackSheep applications, meaning that parent applications can expose
183181
OpenAPI Documentation about all endpoints, including those of mounted apps and
@@ -307,6 +305,7 @@ Produces OpenAPI Documentation for all endpoints.
307305
![Mount OAD](./img/mount-oad.png)
308306

309307
## Examples
308+
310309
To see a working example where `mount` is used, see [the Piccolo Admin example
311310
at
312311
_BlackSheep-Examples_](https://github.com/Neoteroi/BlackSheep-Examples/tree/main/piccolo-admin).

0 commit comments

Comments
 (0)