Skip to content

Commit

Permalink
fix: set current version on http response headers
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-Shen committed Feb 12, 2025
1 parent 7f17eb7 commit 5d2d23a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion labelu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typer import Typer
from fastapi import FastAPI, Request, Response
from fastapi.staticfiles import StaticFiles
from importlib.metadata import version

from labelu.internal.adapter.routers import add_router
from labelu.internal.middleware import add_middleware
Expand Down Expand Up @@ -69,11 +70,12 @@
},
]

labelu_version = version('labelu')

app = FastAPI(
title="labelU",
description=description,
version="0.1.0",
version=labelu_version,
terms_of_service="",
contact={
"name": "labelu",
Expand Down Expand Up @@ -119,6 +121,8 @@ def file_response(self, *args: Any, **kwargs: Any) -> Response:
async def add_correct_content_type(request: Request, call_next):
response = await call_next(request)

response.headers["LabelU-Version"] = labelu_version

if request.url.path.endswith(".js"):
response.headers["content-type"] = "application/javascript"
return response
Expand Down

0 comments on commit 5d2d23a

Please sign in to comment.