Skip to content

Adding Cors handler to http request handler in netty server #756

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

Merged
merged 11 commits into from
Jun 12, 2025

Conversation

dpacheco-groupieticket
Copy link
Contributor

Issue #737

Description

Netty service

This PR contains a new handler to respond with require headers when smithy.api#cors trait is set in the service.

The CorsHandler supports the case of having multiple origins, when the origin value contains multiple origins separated by commas it will check against the origin in attached in the request.

Json Serializer Test fix.

The testPrettyPrinting() test fails due to differences in line endings between operating systems. Windows uses \r\n (CRLF), while Unix-based systems (Linux/macOS) use \n (LF). The expected string, defined in a Java text block, contains Unix-style line endings (\n), but the actual output (result) contains Windows-style line endings (\r\n), causing the assertion to mismatch despite identical content. To ensure consistent behavior across platforms, we normalize line endings by removing \r before comparison or use System.lineSeparator() for OS-agnostic formatting.

Test

No unit tests are configure for the netty-server subpackage. I manually tested from an external project and the requests returns the expected headers.

@rhernandez35
Copy link
Contributor

Thank you for the PR!

Comment on lines 53 to 54
var corsTrait = job.operation().getApiOperation()
.service()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var corsTrait = job.operation().getApiOperation()
.service()
var corsTrait = job.operation()
.getApiOperation()
.service()

@rhernandez35
Copy link
Contributor

Can you run ./gradlew spotlessApply and push the changes?

@rhernandez35 rhernandez35 enabled auto-merge (rebase) June 12, 2025 00:40
@rhernandez35 rhernandez35 merged commit d928df3 into smithy-lang:main Jun 12, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants