Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for call_next (0.17 sec)

  1. tests/test_dependency_contextmanager.py

        tasks.add_task(bg, state)
        return state
    
    
    @app.middleware("http")
    async def middleware(request, call_next):
        response: StreamingResponse = await call_next(request)
        response.headers["x-state"] = json.dumps(state.copy())
        return response
    
    
    client = TestClient(app)
    
    
    def test_async_state():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 11.6K bytes
    - Viewed (0)
  2. fastapi/applications.py

            from fastapi import FastAPI, Request
    
            app = FastAPI()
    
    
            @app.middleware("http")
            async def add_process_time_header(request: Request, call_next):
                start_time = time.time()
                response = await call_next(request)
                process_time = time.time() - start_time
                response.headers["X-Process-Time"] = str(process_time)
                return response
            ```
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 172.2K bytes
    - Viewed (0)
Back to top