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

feat(common) #62: Message routing headers #70

Merged
merged 8 commits into from
Jan 19, 2024

Conversation

lilgallon
Copy link
Member

@lilgallon lilgallon commented Jan 17, 2024

// This is an example, you will probably need something more specific
// if you want to handle message routing headers
val requestMessageRoutingHeaders = currentRequestMessageRoutingHeadersOrNull()
val responseMessageRoutingHeaders = currentResponseMessageRoutingHeaders()
Copy link
Contributor

@atschabu atschabu Jan 18, 2024

Choose a reason for hiding this comment

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

may I suggest adding a method to the RequestMessageRoutingHeaders that inverts itself? Something like

invert(): ResponseMessageRoutingHeaders

alternative names could be toResponseRoutingHeaders, toResponse

or alternatively have a secondary constructor on the ResponseMessageRoutingHeaders

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I like the idea.
About the name, at firs glance t I liked invert, but it makes me feel it will return an inverted request routing headers. Therefore I would prefer toResponse despite it doesn't convey the inversion.

Alternatively it could be a companion object method on the response, so that you would use it like this: ResponseMessageRoutingHeaders.invertFromRequest(requestMessageRoutingHeaders)

That's longer but I think it's more explicit.

@@ -63,7 +60,9 @@ class Http4kTransportServer(
}
.also { httpRequest -> filters.forEach { filter -> filter(httpRequest) } }
.let { httpRequest ->
httpRequest to runBlocking {
httpRequest to runBlocking(
httpRequest.messageRoutingHeaders() + ResponseMessageRoutingHeaders()
Copy link
Contributor

Choose a reason for hiding this comment

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

should we "invert" by default. unless you implement a HUB, a server would always need to mirror the clients routing headers. Similar to how we already handle request/response message ID headers automatically.

Copy link
Contributor

Choose a reason for hiding this comment

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

Absolutely, good suggestion!

@lilgallon lilgallon marked this pull request as ready for review January 18, 2024 10:37
@lilgallon lilgallon requested a review from xhanin January 18, 2024 13:26
Copy link
Contributor

@xhanin xhanin left a comment

Choose a reason for hiding this comment

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

good for me

@lilgallon lilgallon force-pushed the feat/#62-provide-context-with-from-to-headers branch from 7169cf5 to 0911532 Compare January 19, 2024 20:41
@lilgallon lilgallon merged commit 5ebdf8b into main Jan 19, 2024
1 check passed
Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

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.

Paginated response header override all other headers Provide request context to services
3 participants