goatseo-fastapi 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,6 @@
1
+ """FastAPI integration for GoatSEO."""
2
+
3
+ from goatseo.fastapi.integration import GoatSEO, goatseo_head, request_context
4
+ from goatseo.seo import SEO
5
+
6
+ __all__ = ["SEO", "GoatSEO", "goatseo_head", "request_context"]
@@ -0,0 +1,35 @@
1
+ """FastAPI integration built on dependency injection and Jinja2 templates."""
2
+
3
+ from starlette.requests import Request
4
+ from starlette.templating import Jinja2Templates
5
+
6
+ from goatseo.core import Metadata, SafeHtml, StaticRequestContext
7
+ from goatseo.seo import SEO
8
+
9
+
10
+ def request_context(request: Request) -> StaticRequestContext:
11
+ return StaticRequestContext(str(request.url))
12
+
13
+
14
+ def goatseo_head(seo: SEO, request: Request) -> SafeHtml:
15
+ return seo.render(request_context(request))
16
+
17
+
18
+ class GoatSEO:
19
+ """A dependency that gives each request a fresh :class:`SEO` built from site defaults.
20
+
21
+ ``SEODep = Annotated[SEO, Depends(GoatSEO(defaults=...))]``; FastAPI caches it per request.
22
+ """
23
+
24
+ __slots__ = ("defaults",)
25
+
26
+ def __init__(self, defaults: Metadata | None = None) -> None:
27
+ self.defaults = defaults
28
+
29
+ def __call__(self) -> SEO:
30
+ return SEO(defaults=self.defaults)
31
+
32
+ def install(self, templates: Jinja2Templates) -> None:
33
+ """Exposes ``{{ goatseo_head(seo, request) }}`` to the templates."""
34
+ # Jinja infers Environment.globals from its default entries, which rejects any callable.
35
+ templates.env.globals["goatseo_head"] = goatseo_head # pyright: ignore[reportArgumentType]
File without changes
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.4
2
+ Name: goatseo-fastapi
3
+ Version: 0.1.0
4
+ Summary: FastAPI integration for GoatSEO.
5
+ Keywords: seo,schema.org,json-ld,opengraph,twitter-cards,metadata
6
+ Author: Louis Midson LAJEANTY
7
+ Author-email: Louis Midson LAJEANTY <midsonlajeanty@proton.me>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Framework :: FastAPI
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
17
+ Classifier: Typing :: Typed
18
+ Requires-Dist: goatseo-seo==0.1.0
19
+ Requires-Dist: fastapi>=0.115
20
+ Requires-Python: >=3.14
21
+ Project-URL: Homepage, https://github.com/goatlabshq/goatseo
22
+ Project-URL: Documentation, https://goatlabshq.github.io/goatseo/
23
+ Project-URL: Issues, https://github.com/goatlabshq/goatseo/issues
24
+ Description-Content-Type: text/markdown
25
+
26
+ # goatseo-fastapi
27
+
28
+ FastAPI integration for GoatSEO: a per-request `SEO` dependency and a Jinja2 `goatseo_head` helper.
29
+
30
+ ```bash
31
+ pip install "goatseo[fastapi]"
32
+ ```
33
+
34
+ ```python
35
+ from typing import Annotated
36
+ from fastapi import Depends
37
+ from goatseo.fastapi import SEO, GoatSEO
38
+
39
+ SEODep = Annotated[SEO, Depends(GoatSEO())]
40
+ ```
41
+
42
+ Part of [GoatSEO](https://github.com/goatlabshq/goatseo). See the [documentation](https://goatlabshq.github.io/goatseo/).
@@ -0,0 +1,7 @@
1
+ goatseo/fastapi/__init__.py,sha256=sFdsI0RapcQSXbM89wOKofMit1xnS7JylGsp0KVTyVI,212
2
+ goatseo/fastapi/integration.py,sha256=QCIzkCzZAv6FfwxRXIOUmEC9Vprd4IGpfNQICPB5goQ,1238
3
+ goatseo/fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ goatseo_fastapi-0.1.0.dist-info/licenses/LICENSE,sha256=Zcs5rp01UDASfBq28ErEU7tdk14P5WTR3zNmlaZKnkA,1105
5
+ goatseo_fastapi-0.1.0.dist-info/WHEEL,sha256=oBPtwmRtX9fzUVIGqTf2NA4uW8MUj4N1HrmGwtPkDyA,80
6
+ goatseo_fastapi-0.1.0.dist-info/METADATA,sha256=KyyZeocyvJNPqbMOkL6y72No2s_iq7y2rEHr6bLNkeA,1432
7
+ goatseo_fastapi-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.13.2
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Louis Midson LAJEANTY <midsonlajeanty@proton.me>
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.