Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 72 for middleware (0.07 sec)

  1. docs/em/docs/tutorial/middleware.md

    ///
    
    ## ✍ 🛠️
    
    ✍ 🛠️ 👆 ⚙️ 👨‍🎨 `@app.middleware("http")` 🔛 🔝 🔢.
    
    🛠️ 🔢 📨:
    
    *  `request`.
    * 🔢 `call_next` 👈 🔜 📨 `request` 🔢.
        * 👉 🔢 🔜 🚶‍♀️ `request` 🔗 *➡ 🛠️*.
        * ⤴️ ⚫️ 📨 `response` 🏗 🔗 *➡ 🛠️*.
    * 👆 💪 ⤴️ 🔀 🌅 `response` ⏭ 🛬 ⚫️.
    
    ```Python hl_lines="8-9  11  14"
    {!../../docs_src/middleware/tutorial001.py!}
    ```
    
    /// tip
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 2.4K bytes
    - Viewed (0)
  2. docs/zh/docs/tutorial/middleware.md

    在任何*路径操作*收到`request`前,可以添加要和请求一起运行的代码.
    
    也可以在*响应*生成但是返回之前添加代码.
    
    例如你可以添加自定义请求头 `X-Process-Time` 包含以秒为单位的接收请求和生成响应的时间:
    
    ```Python hl_lines="10  12-13"
    {!../../docs_src/middleware/tutorial001.py!}
    ```
    
    ## 其他中间件
    
    你可以稍后在 [Advanced User Guide: Advanced Middleware](../advanced/middleware.md){.internal-link target=_blank}阅读更多关于中间件的教程.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 2.7K bytes
    - Viewed (0)
  3. docs/zh/docs/advanced/middleware.md

    ```
    
    `app.add_middleware()` 的第一个参数是中间件的类,其它参数则是要传递给中间件的参数。
    
    ## 集成中间件
    
    **FastAPI** 为常见用例提供了一些中间件,下面介绍怎么使用这些中间件。
    
    /// note | "技术细节"
    
    以下几个示例中也可以使用 `from starlette.middleware.something import SomethingMiddleware`。
    
    **FastAPI** 在 `fastapi.middleware` 中提供的中间件只是为了方便开发者使用,但绝大多数可用的中间件都直接继承自 Starlette。
    
    ///
    
    ## `HTTPSRedirectMiddleware`
    
    强制所有传入请求必须是 `https` 或 `wss`。
    
    任何传向 `http` 或 `ws` 的请求都会被重定向至安全方案。
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.5K bytes
    - Viewed (0)
  4. docs/ja/docs/tutorial/middleware.md

    ///
    
    ## ミドルウェアの作成
    
    ミドルウェアを作成するには、関数の上部でデコレータ `@app.middleware("http")` を使用します。
    
    ミドルウェア関数は以下を受け取ります:
    
    * `request`。
    * パラメータとして `request` を受け取る関数 `call_next`。
        * この関数は、対応する*path operation*に `request` を渡します。
        * 次に、対応する*path operation*によって生成された `response` を返します。
    * その後、`response` を返す前にさらに `response` を変更することもできます。
    
    ```Python hl_lines="8-9  11  14"
    {!../../docs_src/middleware/tutorial001.py!}
    ```
    
    /// tip | "豆知識"
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.8K bytes
    - Viewed (0)
  5. docs/pt/docs/tutorial/cors.md

    Você também pode usar `from starlette.middleware.cors import CORSMiddleware`.
    
    **FastAPI** fornece vários middlewares em `fastapi.middleware` apenas como uma conveniência para você, o desenvolvedor. Mas a maioria dos middlewares disponíveis vêm diretamente da Starlette.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 5.5K bytes
    - Viewed (0)
  6. tests/test_ws_router.py

        Verify that it is possible to write custom WebSocket middleware to catch errors
        """
    
        @websocket_middleware
        async def errorhandler(websocket: WebSocket, call_next):
            try:
                return await call_next()
            except Exception as e:
                await websocket.close(code=status.WS_1006_ABNORMAL_CLOSURE, reason=repr(e))
    
        myapp = make_app(middleware=[Middleware(errorhandler)])
        client = TestClient(myapp)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Jun 11 19:08:14 UTC 2023
    - 7.5K bytes
    - Viewed (0)
  7. tests/test_custom_middleware_exception.py

    from fastapi.exceptions import HTTPException
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    router = APIRouter()
    
    
    class ContentSizeLimitMiddleware:
        """Content size limiting middleware for ASGI applications
        Args:
          app (ASGI application): ASGI application
          max_content_size (optional): the maximum content size allowed in bytes, None for no limit
        """
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Aug 25 21:44:40 UTC 2022
    - 2.8K bytes
    - Viewed (0)
  8. docs/ru/docs/tutorial/cors.md

    /// note | "Технические детали"
    
    Вы также можете использовать `from starlette.middleware.cors import CORSMiddleware`.
    
    **FastAPI** предоставляет несколько middleware в `fastapi.middleware` только для вашего удобства как разработчика. Но большинство доступных middleware взяты напрямую из Starlette.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 8.3K bytes
    - Viewed (0)
  9. fastapi/middleware/__init__.py

    from starlette.middleware import Middleware as Middleware...
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Dec 20 18:50:00 UTC 2020
    - 58 bytes
    - Viewed (0)
  10. cmd/routers.go

    }
    
    // List of some generic middlewares which are applied for all incoming requests.
    var globalMiddlewares = []mux.MiddlewareFunc{
    	// set x-amz-request-id header and others
    	addCustomHeadersMiddleware,
    	// The generic tracer needs to be the first middleware to catch all requests
    	// returned early by any other middleware (but after the middleware that
    	// sets the amz request id).
    	httpTracerMiddleware,
    Registered: Sun Nov 03 19:28:11 UTC 2024
    - Last Modified: Mon Jul 29 18:10:04 UTC 2024
    - 3.9K bytes
    - Viewed (0)
Back to top