You are viewing the local version of the documentation. Click here to go to the latest version.

Litestar Litestar Litestar
  • 主頁
    • 參與貢獻 了解參與貢獻 Litestar 專案的方式
    • 行為守則 Review the etiquette for interacting with the Litestar community
    • 安全性 Litestar 安全協定概覽
    • Litestar 組織 關於 Litestar 組織的詳細資訊
    • 發行版 探索 Litestar 的發行過程、版本控制與棄用方針
    • 3.0 版本的新內容 探索 Litestar 3.0 的新功能
    • 3.x 變更日誌 3.x 系列的所有變更
    • 2.x 變更日誌 2.x 系列的所有變更
    • Discord 幫助論壇 Dedicated Discord help forum
    • GitHub Discussions GitHub Discussions
    • Stack Overflow We monitor the litestar tag on Stack Overflow
  • 贊助者
/
  • latest
  • v3 (development)
  • v2
  • v1
  • Discussion

文件

  • 開始使用
  • Usage
    • Applications
    • Routing
      • 概覽
      • Route handlers
      • 參數
    • Requests
    • Caching
    • Channels
    • CLI
    • 資料庫
      • SQLAlchemy
        • SQLAlchemy Models & Repository
        • Plugins
      • Piccolo ORM
    • 除錯
    • Dependency Injection
    • Data Transfer Object (DTO)
      • Basic Use
      • AbstractDTO
      • Implementing Custom DTO Classes
    • Events
    • Exceptions and exception handling
    • 檔案系統
    • HTMX
    • Life Cycle Hooks
    • Request logging
    • Metrics
      • OpenTelemetry
      • Prometheus
    • 中介軟體
      • 使用中介軟體
      • Built-in middleware
      • Creating Middleware
    • OpenAPI
      • Configuring schema generation
      • Configuring schema generation on a route handler
      • Accessing the OpenAPI schema in code
      • Customizing Pydantic model schemas
      • Customizing Operation class
      • Generating examples
      • OpenAPI UI 插件
      • 使用 OpenAPI UI 插件
      • Configuring OpenAPI UI Plugins
      • Configuring the OpenAPI Root Path
      • Building your own OpenAPI UI Plugin
      • Interacting with the Router
      • OAuth2 in Swagger UI
      • CDN and offline file support
    • Plugins
      • Flash Messages
      • Problem Details
    • Responses
    • 安全性
      • Implementing Custom Authentication
      • Security Backends
      • Guards
      • Excluding and including endpoints
      • JWT Security Backends
      • Handling Secrets
    • Static files
    • Custom types
    • Stores
    • Templating
    • 測試
    • WebSockets
  • API 參考
    • app
    • background_tasks
    • channels
      • plugin
      • subscriber
      • backends
        • base
        • memory
        • redis
        • psycopg
        • asyncpg
    • cli
    • config
    • connection
    • contrib
      • jinja
      • mako
      • opentelemetry
    • controller
    • concurrency
    • data_extractors
    • datastructures
      • secret_values
    • di
    • dto
      • config
      • data_structures
      • field
      • types
      • base_dto
      • msgspec_dto
      • dataclass_dto
    • enums
    • events
    • exceptions
    • file_system
    • handlers
    • middleware
      • allowed_hosts
      • authentication
      • compression
      • csrf
      • logging
      • rate_limit
      • session
        • base
        • client_side
        • server_side
      • constraints
    • openapi
      • openapi
      • plugins
      • spec
    • pagination
    • params
    • plugins
      • attrs
      • flash
      • htmx
      • problem details
      • prometheus
      • pydantic
    • repository
      • abc
      • filters
      • exceptions
      • testing
      • handlers
    • response
      • base
      • file
      • redirect
      • streaming
      • SSE (Server Sent Events)
      • template
    • router
    • routes
    • security
      • jwt
      • session_auth
    • serialization
    • static_files
    • status_code
    • stores
      • base
      • file
      • memory
      • redis
      • registry
      • valkey
    • template
    • testing
    • types
    • typing
  • 基準測試

指南

  • 遷移至 Litestar
    • From Flask
    • From Starlette / FastAPI
  • 話題
    • Sync vs. Async
    • 部署
      • 手動使用 ASGI 伺服器
      • Docker
      • Supervisor (Linux)
  • Tutorials
    • Developing a basic TODO application
      • Application basics
      • Accessing the list
      • Making the list interactive
      • Recap and assembling the final application
    • Improving the TODO app with SQLAlchemy
      • 介紹
      • Providing the session with DI
      • Using the serialization plugin
      • 使用初始化插件
      • Final touches and recap
    • Data Transfer Object Tutorial
      • Our first DTO
      • Excluding from nested models
      • Excluding from collections of nested models
      • Max nested depth
      • Renaming fields
      • Receiving data
      • Read only fields
      • Accessing the data
      • Updating instances
      • Declaring DTOs on app layers
    • SQLAlchemy Repository Tutorial
      • Introduction to Database Modelling and Repository Features
      • Modelling
      • Full Code
      • Interacting with repositories
      • Working with Bulk Data Operations
      • Full Code
      • Working with Controllers and Repositories
      • Full Code
      • Adding Additional Features to the Repository
      • Slug Fields
      • Full Code

參與貢獻

  • 貢獻指南
  • Available Issues
  • 行為守則
litestar-org/litestar 0 0
編輯此頁面
  1. Litestar /
  2. Usage /
  3. 中介軟體

中介軟體¶

Middlewares in Litestar are ASGI apps that are called "in the middle" between the application entrypoint and the route handler function.

Litestar ships with several builtin middlewares that are easy to configure and use. See the documentation regarding these for more details.

也參考

If you're coming from Starlette / FastAPI, take a look at the migration guide:

  • Migration - FastAPI/Starlette - Middlewares

  • 使用中介軟體
  • Built-in middleware
  • Creating Middleware
上一頁
Prometheus
下一頁
使用中介軟體

2026, Litestar Organization

Made with Sphinx and Shibuya theme.