add in-memory cache to /api/v1/api endpoint

This commit is contained in:
austnv
2026-06-14 22:45:59 +03:00
parent e0c85f3523
commit cdcbf0b622
+3
View File
@@ -3,6 +3,7 @@ from typing import Optional, Dict, Any, Tuple
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from fastapi import APIRouter, Request from fastapi import APIRouter, Request
from functools import lru_cache
from httpx import AsyncClient from httpx import AsyncClient
@@ -166,6 +167,8 @@ class IPInfo:
# ==================== Роутер ==================== # ==================== Роутер ====================
router = APIRouter(prefix='/api/v1', tags=['ip']) router = APIRouter(prefix='/api/v1', tags=['ip'])
@lru_cache
@router.get('/ip') @router.get('/ip')
async def get_ip(request: Request): async def get_ip(request: Request):
forwarded = request.headers.get('X-Forwarded-For') forwarded = request.headers.get('X-Forwarded-For')