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

Include x-request-id as header response #95

Conversation

tonykhaov
Copy link

πŸ”— Linked issue

#93

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This includes x-request-id in the response headers
Resolves #93

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@tonykhaov
Copy link
Author

tonykhaov commented Nov 26, 2024

Hey this is in draft because I want to make sure that I'm on the right path I'd be happy to get some help from you!
I'll need to clean up the code, add code comments, write test for it and update documentation

assert.deepEqual(body, {
enabled: true,
get: true,
getOrFail: true,
})

assert.exists(headers['x-request-id'])
Copy link
Author

Choose a reason for hiding this comment

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

this was just a quick check, I'll write a new test for the feature

@nadlgit
Copy link

nadlgit commented Nov 27, 2024

Hi, I also started to work on it but stopped as I saw your PR.

As for testing, I would replicate in tests/response.spec.ts the one named "generate etag when set to true" on line 934 and adapt it for X-Request-Id.

*
*/
if (this.#config.generateRequestId) {
this.header('X-Request-Id', this.request.headers['x-request-id'])
Copy link
Member

Choose a reason for hiding this comment

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

I think the X-Request-Id should be set if its available in the request headers, regardless of whether it is enabled within the AdonisJS app or not.

This is because, the frontend might set the header, the backend app never generates it and re-uses the existing header and in that case, we still want the id to exist in the response.

@tonykhaov
Copy link
Author

Hi, I also started to work on it but stopped as I saw your PR.

As for testing, I would replicate in tests/response.spec.ts the one named "generate etag when set to true" on line 934 and adapt it for X-Request-Id.

Hey mate you can take over the PR as I won't have much time to finish it!

@thetutlage
Copy link
Member

Closed by #96

@thetutlage thetutlage closed this Nov 28, 2024
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.

RequestId is not inclkuded in response header
3 participants