Skip to content

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

@vsutskever

Description

@vsutskever

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`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions