fastapi-extended-query-method 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastapi_extended_query_method-0.0.3/LICENSE +21 -0
- fastapi_extended_query_method-0.0.3/PKG-INFO +122 -0
- fastapi_extended_query_method-0.0.3/README.md +83 -0
- fastapi_extended_query_method-0.0.3/fastapi_extended_query_method.egg-info/PKG-INFO +122 -0
- fastapi_extended_query_method-0.0.3/fastapi_extended_query_method.egg-info/SOURCES.txt +10 -0
- fastapi_extended_query_method-0.0.3/fastapi_extended_query_method.egg-info/dependency_links.txt +1 -0
- fastapi_extended_query_method-0.0.3/fastapi_extended_query_method.egg-info/requires.txt +5 -0
- fastapi_extended_query_method-0.0.3/fastapi_extended_query_method.egg-info/top_level.txt +1 -0
- fastapi_extended_query_method-0.0.3/setup.cfg +4 -0
- fastapi_extended_query_method-0.0.3/setup.py +53 -0
- fastapi_extended_query_method-0.0.3/src/__init__.py +0 -0
- fastapi_extended_query_method-0.0.3/src/fastapi_extended_query_method.py +85 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JorgeCardona
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastapi-extended-query-method
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Native HTTP QUERY method support for FastAPI with automatic cache control and Swagger compatibility.
|
|
5
|
+
Home-page: https://github.com/jorgecardona/fastapi-extended-query-method
|
|
6
|
+
Author: Jorge Cardona
|
|
7
|
+
Keywords: fastapi,query,http-query,openapi,swagger,rest,api,middleware
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Framework :: FastAPI
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: fastapi>=0.139.0
|
|
25
|
+
Requires-Dist: uvicorn>=0.5.1
|
|
26
|
+
Requires-Dist: requests>=2.34.2
|
|
27
|
+
Requires-Dist: requests-cache>=1.3.3
|
|
28
|
+
Requires-Dist: tabulate>=0.10.0
|
|
29
|
+
Dynamic: author
|
|
30
|
+
Dynamic: classifier
|
|
31
|
+
Dynamic: description
|
|
32
|
+
Dynamic: description-content-type
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: keywords
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: requires-python
|
|
38
|
+
Dynamic: summary
|
|
39
|
+
|
|
40
|
+
# FastAPI Extended Query Method
|
|
41
|
+
|
|
42
|
+
Native HTTP QUERY support for FastAPI.
|
|
43
|
+
|
|
44
|
+
## Overview
|
|
45
|
+
|
|
46
|
+
`FastAPIWithQueryHttpMethod` extends FastAPI with native support for the
|
|
47
|
+
HTTP QUERY method while preserving the FastAPI developer experience.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
``` bash
|
|
52
|
+
pip install fastapi-extended-query-method
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
``` python
|
|
58
|
+
from src.fastapi_extended_query_method import FastAPIWithQueryHttpMethod
|
|
59
|
+
|
|
60
|
+
app = FastAPIWithQueryHttpMethod(query_saving_cache=True)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Swagger compatibility
|
|
64
|
+
|
|
65
|
+
After starting the application:
|
|
66
|
+
|
|
67
|
+
http://localhost:8000/docs
|
|
68
|
+
|
|
69
|
+
OpenAPI and Swagger do **not** currently support the HTTP QUERY method.
|
|
70
|
+
|
|
71
|
+
For that reason this package automatically exposes QUERY endpoints as
|
|
72
|
+
both:
|
|
73
|
+
|
|
74
|
+
- QUERY
|
|
75
|
+
- POST
|
|
76
|
+
|
|
77
|
+
Use the **POST** operation in Swagger only for interactive testing.
|
|
78
|
+
|
|
79
|
+
Real clients should invoke the QUERY method directly.
|
|
80
|
+
|
|
81
|
+
<p align="center">
|
|
82
|
+
<img src="images/swagger.png" alt="Swagger Interface" width="900">
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
## Cache
|
|
86
|
+
|
|
87
|
+
`query_saving_cache=True` allows caching.
|
|
88
|
+
|
|
89
|
+
`query_saving_cache=False` automatically adds:
|
|
90
|
+
|
|
91
|
+
- Cache-Control: no-store
|
|
92
|
+
- Pragma: no-cache
|
|
93
|
+
- Expires: 0
|
|
94
|
+
|
|
95
|
+
## Testing API
|
|
96
|
+
|
|
97
|
+
``` bash
|
|
98
|
+
python validate_data/test_api_query_method.py
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
<p align="center">
|
|
102
|
+
<img src="images/api_results.png" alt="API Results" width="900">
|
|
103
|
+
</p>
|
|
104
|
+
|
|
105
|
+
## Testing Cache
|
|
106
|
+
|
|
107
|
+
### Using Cache Stored
|
|
108
|
+
``` bash
|
|
109
|
+
python validate_data/test_cache_comparison.py
|
|
110
|
+
```
|
|
111
|
+
<p align="center">
|
|
112
|
+
<img src="images/cache.png" alt="Stored Cache" width="900">
|
|
113
|
+
</p>
|
|
114
|
+
|
|
115
|
+
### NO Using Cache Stored
|
|
116
|
+
<p align="center">
|
|
117
|
+
<img src="images/no_cache.png" alt="Without Cache" width="900">
|
|
118
|
+
</p>
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# FastAPI Extended Query Method
|
|
2
|
+
|
|
3
|
+
Native HTTP QUERY support for FastAPI.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`FastAPIWithQueryHttpMethod` extends FastAPI with native support for the
|
|
8
|
+
HTTP QUERY method while preserving the FastAPI developer experience.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
``` bash
|
|
13
|
+
pip install fastapi-extended-query-method
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
``` python
|
|
19
|
+
from src.fastapi_extended_query_method import FastAPIWithQueryHttpMethod
|
|
20
|
+
|
|
21
|
+
app = FastAPIWithQueryHttpMethod(query_saving_cache=True)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Swagger compatibility
|
|
25
|
+
|
|
26
|
+
After starting the application:
|
|
27
|
+
|
|
28
|
+
http://localhost:8000/docs
|
|
29
|
+
|
|
30
|
+
OpenAPI and Swagger do **not** currently support the HTTP QUERY method.
|
|
31
|
+
|
|
32
|
+
For that reason this package automatically exposes QUERY endpoints as
|
|
33
|
+
both:
|
|
34
|
+
|
|
35
|
+
- QUERY
|
|
36
|
+
- POST
|
|
37
|
+
|
|
38
|
+
Use the **POST** operation in Swagger only for interactive testing.
|
|
39
|
+
|
|
40
|
+
Real clients should invoke the QUERY method directly.
|
|
41
|
+
|
|
42
|
+
<p align="center">
|
|
43
|
+
<img src="images/swagger.png" alt="Swagger Interface" width="900">
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
## Cache
|
|
47
|
+
|
|
48
|
+
`query_saving_cache=True` allows caching.
|
|
49
|
+
|
|
50
|
+
`query_saving_cache=False` automatically adds:
|
|
51
|
+
|
|
52
|
+
- Cache-Control: no-store
|
|
53
|
+
- Pragma: no-cache
|
|
54
|
+
- Expires: 0
|
|
55
|
+
|
|
56
|
+
## Testing API
|
|
57
|
+
|
|
58
|
+
``` bash
|
|
59
|
+
python validate_data/test_api_query_method.py
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
<p align="center">
|
|
63
|
+
<img src="images/api_results.png" alt="API Results" width="900">
|
|
64
|
+
</p>
|
|
65
|
+
|
|
66
|
+
## Testing Cache
|
|
67
|
+
|
|
68
|
+
### Using Cache Stored
|
|
69
|
+
``` bash
|
|
70
|
+
python validate_data/test_cache_comparison.py
|
|
71
|
+
```
|
|
72
|
+
<p align="center">
|
|
73
|
+
<img src="images/cache.png" alt="Stored Cache" width="900">
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
### NO Using Cache Stored
|
|
77
|
+
<p align="center">
|
|
78
|
+
<img src="images/no_cache.png" alt="Without Cache" width="900">
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
MIT
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastapi-extended-query-method
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Native HTTP QUERY method support for FastAPI with automatic cache control and Swagger compatibility.
|
|
5
|
+
Home-page: https://github.com/jorgecardona/fastapi-extended-query-method
|
|
6
|
+
Author: Jorge Cardona
|
|
7
|
+
Keywords: fastapi,query,http-query,openapi,swagger,rest,api,middleware
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Framework :: FastAPI
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: fastapi>=0.139.0
|
|
25
|
+
Requires-Dist: uvicorn>=0.5.1
|
|
26
|
+
Requires-Dist: requests>=2.34.2
|
|
27
|
+
Requires-Dist: requests-cache>=1.3.3
|
|
28
|
+
Requires-Dist: tabulate>=0.10.0
|
|
29
|
+
Dynamic: author
|
|
30
|
+
Dynamic: classifier
|
|
31
|
+
Dynamic: description
|
|
32
|
+
Dynamic: description-content-type
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: keywords
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: requires-python
|
|
38
|
+
Dynamic: summary
|
|
39
|
+
|
|
40
|
+
# FastAPI Extended Query Method
|
|
41
|
+
|
|
42
|
+
Native HTTP QUERY support for FastAPI.
|
|
43
|
+
|
|
44
|
+
## Overview
|
|
45
|
+
|
|
46
|
+
`FastAPIWithQueryHttpMethod` extends FastAPI with native support for the
|
|
47
|
+
HTTP QUERY method while preserving the FastAPI developer experience.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
``` bash
|
|
52
|
+
pip install fastapi-extended-query-method
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
``` python
|
|
58
|
+
from src.fastapi_extended_query_method import FastAPIWithQueryHttpMethod
|
|
59
|
+
|
|
60
|
+
app = FastAPIWithQueryHttpMethod(query_saving_cache=True)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Swagger compatibility
|
|
64
|
+
|
|
65
|
+
After starting the application:
|
|
66
|
+
|
|
67
|
+
http://localhost:8000/docs
|
|
68
|
+
|
|
69
|
+
OpenAPI and Swagger do **not** currently support the HTTP QUERY method.
|
|
70
|
+
|
|
71
|
+
For that reason this package automatically exposes QUERY endpoints as
|
|
72
|
+
both:
|
|
73
|
+
|
|
74
|
+
- QUERY
|
|
75
|
+
- POST
|
|
76
|
+
|
|
77
|
+
Use the **POST** operation in Swagger only for interactive testing.
|
|
78
|
+
|
|
79
|
+
Real clients should invoke the QUERY method directly.
|
|
80
|
+
|
|
81
|
+
<p align="center">
|
|
82
|
+
<img src="images/swagger.png" alt="Swagger Interface" width="900">
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
## Cache
|
|
86
|
+
|
|
87
|
+
`query_saving_cache=True` allows caching.
|
|
88
|
+
|
|
89
|
+
`query_saving_cache=False` automatically adds:
|
|
90
|
+
|
|
91
|
+
- Cache-Control: no-store
|
|
92
|
+
- Pragma: no-cache
|
|
93
|
+
- Expires: 0
|
|
94
|
+
|
|
95
|
+
## Testing API
|
|
96
|
+
|
|
97
|
+
``` bash
|
|
98
|
+
python validate_data/test_api_query_method.py
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
<p align="center">
|
|
102
|
+
<img src="images/api_results.png" alt="API Results" width="900">
|
|
103
|
+
</p>
|
|
104
|
+
|
|
105
|
+
## Testing Cache
|
|
106
|
+
|
|
107
|
+
### Using Cache Stored
|
|
108
|
+
``` bash
|
|
109
|
+
python validate_data/test_cache_comparison.py
|
|
110
|
+
```
|
|
111
|
+
<p align="center">
|
|
112
|
+
<img src="images/cache.png" alt="Stored Cache" width="900">
|
|
113
|
+
</p>
|
|
114
|
+
|
|
115
|
+
### NO Using Cache Stored
|
|
116
|
+
<p align="center">
|
|
117
|
+
<img src="images/no_cache.png" alt="Without Cache" width="900">
|
|
118
|
+
</p>
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
fastapi_extended_query_method.egg-info/PKG-INFO
|
|
5
|
+
fastapi_extended_query_method.egg-info/SOURCES.txt
|
|
6
|
+
fastapi_extended_query_method.egg-info/dependency_links.txt
|
|
7
|
+
fastapi_extended_query_method.egg-info/requires.txt
|
|
8
|
+
fastapi_extended_query_method.egg-info/top_level.txt
|
|
9
|
+
src/__init__.py
|
|
10
|
+
src/fastapi_extended_query_method.py
|
fastapi_extended_query_method-0.0.3/fastapi_extended_query_method.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import setuptools
|
|
3
|
+
|
|
4
|
+
with open("README.md", "r", encoding="utf-8") as file:
|
|
5
|
+
long_description = file.read()
|
|
6
|
+
|
|
7
|
+
# Get version from environment variable or fallback to a default value
|
|
8
|
+
version = os.getenv("PACKAGE_VERSION", "0.0.1") # Default to '0.0.7' if not provided
|
|
9
|
+
|
|
10
|
+
setuptools.setup(
|
|
11
|
+
name="fastapi-extended-query-method",
|
|
12
|
+
version=version, # Use the dynamic version from the environment variable
|
|
13
|
+
author="Jorge Cardona",
|
|
14
|
+
description="Native HTTP QUERY method support for FastAPI with automatic cache control and Swagger compatibility.",
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
url="https://github.com/jorgecardona/fastapi-extended-query-method",
|
|
18
|
+
packages=setuptools.find_packages(),
|
|
19
|
+
include_package_data=True,
|
|
20
|
+
install_requires=[
|
|
21
|
+
"fastapi>=0.139.0",
|
|
22
|
+
"uvicorn>=0.5.1",
|
|
23
|
+
"requests>=2.34.2",
|
|
24
|
+
"requests-cache>=1.3.3",
|
|
25
|
+
"tabulate>=0.10.0",
|
|
26
|
+
],
|
|
27
|
+
classifiers=[
|
|
28
|
+
"Development Status :: 4 - Beta",
|
|
29
|
+
"Framework :: FastAPI",
|
|
30
|
+
"Intended Audience :: Developers",
|
|
31
|
+
"License :: OSI Approved :: MIT License",
|
|
32
|
+
"Operating System :: OS Independent",
|
|
33
|
+
"Programming Language :: Python :: 3",
|
|
34
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
39
|
+
"Topic :: Software Development :: Libraries",
|
|
40
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
41
|
+
],
|
|
42
|
+
keywords=[
|
|
43
|
+
"fastapi",
|
|
44
|
+
"query",
|
|
45
|
+
"http-query",
|
|
46
|
+
"openapi",
|
|
47
|
+
"swagger",
|
|
48
|
+
"rest",
|
|
49
|
+
"api",
|
|
50
|
+
"middleware",
|
|
51
|
+
],
|
|
52
|
+
python_requires=">=3.10",
|
|
53
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from typing import Any, Callable
|
|
2
|
+
from fastapi import FastAPI, Request, Response
|
|
3
|
+
from fastapi.openapi.utils import get_openapi
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
logging.basicConfig(
|
|
7
|
+
level=logging.INFO,
|
|
8
|
+
format="%(levelname)s: %(message)s",
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
class FastAPIWithQueryHttpMethod(FastAPI):
|
|
14
|
+
"""
|
|
15
|
+
[ES] Clase FastAPI modificada que habilita soporte nativo y visual para el método HTTP QUERY
|
|
16
|
+
y permite configurar automáticamente el guardado de caché para dicho método.
|
|
17
|
+
|
|
18
|
+
[EN] Modified FastAPI class that enables native and visual support for the HTTP QUERY method
|
|
19
|
+
and allows configuring cache saving for this method.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
*args: Any,
|
|
25
|
+
query_saving_cache: bool = True,
|
|
26
|
+
**kwargs: Any,
|
|
27
|
+
) -> None:
|
|
28
|
+
super().__init__(*args, **kwargs)
|
|
29
|
+
|
|
30
|
+
self.query_saving_cache = query_saving_cache
|
|
31
|
+
|
|
32
|
+
@self.middleware("http")
|
|
33
|
+
async def add_query_cache_headers(
|
|
34
|
+
request: Request,
|
|
35
|
+
call_next: Callable[[Request], Any],
|
|
36
|
+
) -> Response:
|
|
37
|
+
response: Response = await call_next(request)
|
|
38
|
+
|
|
39
|
+
# [ES] Cuando el modo de guardado de caché está deshabilitado para QUERY,
|
|
40
|
+
# evitamos que clientes, proxies o navegadores almacenen en caché
|
|
41
|
+
# la respuesta, ya que este método puede transportar información
|
|
42
|
+
# sensible.
|
|
43
|
+
#
|
|
44
|
+
# [EN] When cache saving mode is disabled for QUERY,
|
|
45
|
+
# prevent clients, proxies and browsers from caching the response,
|
|
46
|
+
# since this method may carry sensitive information.
|
|
47
|
+
if not self.query_saving_cache and request.method.upper() == "QUERY":
|
|
48
|
+
response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0"
|
|
49
|
+
response.headers["Pragma"] = "no-cache"
|
|
50
|
+
response.headers["Expires"] = "0"
|
|
51
|
+
logger.info("QUERY cache saving is disabled. Clients, browsers, and proxies will not cache responses containing sensitive data.")
|
|
52
|
+
|
|
53
|
+
return response
|
|
54
|
+
|
|
55
|
+
def query(self, path: str, **kwargs: Any) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
|
|
56
|
+
"""
|
|
57
|
+
[ES] Decorador para registrar un endpoint que acepte tanto POST como QUERY.
|
|
58
|
+
Se usa POST para que Swagger UI no lo rompa y permita probarlo desde la web,
|
|
59
|
+
y QUERY para soportar peticiones con dicho método HTTP real.
|
|
60
|
+
|
|
61
|
+
[EN] Decorator to register an endpoint that accepts both POST and QUERY.
|
|
62
|
+
POST is used so Swagger UI doesn't break and allows testing it from the web,
|
|
63
|
+
and QUERY to support requests with that actual HTTP method.
|
|
64
|
+
"""
|
|
65
|
+
return self.api_route(path, methods=["POST", "QUERY"], **kwargs)
|
|
66
|
+
|
|
67
|
+
def openapi(self) -> dict[str, Any]:
|
|
68
|
+
"""
|
|
69
|
+
[ES] Genera el esquema OpenAPI estándar garantizando que la ruta sea visible.
|
|
70
|
+
|
|
71
|
+
[EN] Generates the standard OpenAPI schema ensuring that the route is visible.
|
|
72
|
+
"""
|
|
73
|
+
if self.openapi_schema:
|
|
74
|
+
return self.openapi_schema
|
|
75
|
+
|
|
76
|
+
openapi_schema = get_openapi(
|
|
77
|
+
title=self.title,
|
|
78
|
+
version=self.version,
|
|
79
|
+
openapi_version=self.openapi_version,
|
|
80
|
+
description=self.description,
|
|
81
|
+
routes=self.routes,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
self.openapi_schema = openapi_schema
|
|
85
|
+
return self.openapi_schema
|