Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlaskPyctuator changes content types of unrelated requests when configured on root path "/" #108

Open
vsutskever opened this issue Apr 28, 2024 · 0 comments

Comments

@vsutskever
Copy link

vsutskever commented Apr 28, 2024

If pyctuator is configured to start on "/" - it will modify content types of unrelated requests. A workaround is to initialize pyctuator in a sub path i.e /actuator

The culprit is likely therequest.path.startswith matching inside of FlaskPyctuator (And other adapters) middleware configuration. The

` @app.before_request
def intercept_requests_and_responses() -> None:
request_time = datetime.now()

        @after_this_request
        def after_response(response: Response) -> Response:
            response_time = datetime.now()

            # Set the SBA-V2 content type for responses from Pyctuator
            if request.path.startswith(self.pyctuator_impl.pyctuator_endpoint_path_prefix):
                **response.headers["Content-Type"] = SBA_V2_CONTENT_TYPE**

            # Record the request and response
            self.record_request_and_response(response, request_time, response_time)
            return response`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant