Skip to content

Commit

Permalink
Add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
reweeden committed Mar 19, 2024
1 parent bfb70d0 commit e961c0f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions thin_egress_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ def is_cors_allowed():
origin_header = app.current_request.headers.get("origin")
cors_origin = os.getenv("CORS_ORIGIN")

log.debug("origin_header: %r, cors_origin: %r", origin_header, cors_origin)
return bool(
origin_header
and cors_origin
Expand Down Expand Up @@ -881,17 +882,23 @@ def dynamic_url_options():
"Access-Control-Request-Method",
"",
).strip()
log.info("Received CORS preflight request for method: %r", request_method)

Check warning on line 885 in thin_egress_app/app.py

View check run for this annotation

Codecov / codecov/patch

thin_egress_app/app.py#L885

Added line #L885 was not covered by tests

log.debug("is_cors_allowed: %s", is_cors_allowed())
log.debug("request_method in allowed_methods: %s", request_method in allowed_methods)

Check warning on line 888 in thin_egress_app/app.py

View check run for this annotation

Codecov / codecov/patch

thin_egress_app/app.py#L887-L888

Added lines #L887 - L888 were not covered by tests
if is_cors_allowed() and request_method in allowed_methods:
headers = {

Check warning on line 890 in thin_egress_app/app.py

View check run for this annotation

Codecov / codecov/patch

thin_egress_app/app.py#L890

Added line #L890 was not covered by tests
"Access-Control-Allow-Methods": ", ".join(allowed_methods)
}
add_cors_headers(headers)
log.info("Returning success response")
return Response(

Check warning on line 895 in thin_egress_app/app.py

View check run for this annotation

Codecov / codecov/patch

thin_egress_app/app.py#L893-L895

Added lines #L893 - L895 were not covered by tests
body="",
headers=headers,
status_code=204,
)

log.info("Returning error response")
return Response(

Check warning on line 902 in thin_egress_app/app.py

View check run for this annotation

Codecov / codecov/patch

thin_egress_app/app.py#L901-L902

Added lines #L901 - L902 were not covered by tests
body="Method Not Allowed",
status_code=405,
Expand Down

0 comments on commit e961c0f

Please sign in to comment.