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

refactor: move server.responseHeaders to server.headers.custom #1401

Closed
wants to merge 3 commits into from
Closed

refactor: move server.responseHeaders to server.headers.custom #1401

wants to merge 3 commits into from

Conversation

neo773
Copy link
Contributor

@neo773 neo773 commented Mar 12, 2024

This PR moves server.responseHeaders to server.headers.custom

Issue Reference(s):
Fixes #1400

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

/claim #1400

Summary by CodeRabbit

  • New Features
    • Introduced a new custom directive for specifying key-value pairs in server responses, enhancing customization.
  • Refactor
    • Refined the handling of response headers to utilize a new nested structure for storing custom headers, improving flexibility and organization.
  • Documentation
    • Updated descriptions and structures in documentation to reflect changes in handling key-value pairs and response headers.
  • Tests
    • Adapted tests to align with the new structure for custom headers, ensuring reliability and correctness.

Copy link
Contributor

coderabbitai bot commented Mar 12, 2024

Walkthrough

The update involves shifting the handling of server response headers, replacing responseHeaders with a more flexible custom directive and field for specifying key-value pairs in server responses. This change streamlines the schema and enhances customization options for defining headers.

Changes

File Path Change Summary
generated/.tailcallrc.graphql Removed responseHeaders, added custom directive for key-value pairs in server responses.
generated/.tailcallrc.schema.json Updated to include a custom field for specifying key-value pairs in server responses.
src/config/headers.rs Added custom field of type Option<Vec<KeyValue>> to Headers struct for custom key-value pairs.
src/config/server.rs Refactored to handle response headers using headers.custom for custom headers; updated header manipulation.
tests/execution/custom-headers.md, test-response-headers-* Renamed and adjusted schema declarations to use headers.custom for custom headers in test scenarios.

Assessment against linked issues

Objective Addressed Explanation
Move server.responseHeaders to server.headers.custom (#1400)

Poem

In the realm of code, where rabbits play,
Headers shift in a new display.
From old to custom, a change so bright,
Key-value pairs now take flight.
🐇✨
With headers tailored, responses sing,
A coding tale, a fresh spring fling.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@github-actions github-actions bot added the type: chore Routine tasks like conversions, reorganization, and maintenance work. label Mar 12, 2024
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.31%. Comparing base (3665038) to head (ffd1046).

❗ Current head ffd1046 differs from pull request most recent head 791cf8b. Consider uploading reports for the commit 791cf8b to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1401      +/-   ##
==========================================
- Coverage   88.31%   88.31%   -0.01%     
==========================================
  Files         127      127              
  Lines       13398    13389       -9     
==========================================
- Hits        11833    11825       -8     
+ Misses       1565     1564       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3665038 and ffd1046.
Files ignored due to path filters (2)
  • tests/snapshots/execution_spec__cache-control.md_merged.snap is excluded by: !**/*.snap
  • tests/snapshots/execution_spec__custom-headers.md_merged.snap is excluded by: !**/*.snap
Files selected for processing (8)
  • generated/.tailcallrc.graphql (2 hunks)
  • generated/.tailcallrc.schema.json (2 hunks)
  • src/config/headers.rs (2 hunks)
  • src/config/server.rs (3 hunks)
  • tests/execution/custom-headers.md (2 hunks)
  • tests/execution/test-response-header-value.md (1 hunks)
  • tests/execution/test-response-headers-multi.md (1 hunks)
  • tests/execution/test-response-headers-name.md (1 hunks)
Additional comments: 8
tests/execution/test-response-headers-name.md (1)
  • 6-6: The updated schema declaration for custom headers correctly implements the proposed changes in the PR. This test case effectively demonstrates the new structure for defining custom headers under server.headers.custom.
tests/execution/test-response-header-value.md (1)
  • 6-6: The test case effectively verifies the handling of newline characters in header values within the new headers.custom structure. This ensures that complex header values are supported in the updated configuration.
tests/execution/test-response-headers-multi.md (1)
  • 6-6: The test case effectively verifies the handling of multiple custom headers within the new headers.custom structure. This ensures that the updated configuration supports multiple custom headers without issues.
tests/execution/custom-headers.md (1)
  • 3-10: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [6-17]

The JSON configuration correctly implements the new structure for custom headers, aligning with the PR objectives. This change ensures that custom headers are organized under headers.custom, enhancing clarity and maintainability.

src/config/headers.rs (1)
  • 17-17: The addition of the custom field to the Headers struct is correctly implemented, allowing for a structured approach to defining custom headers in server responses. This change aligns with the PR objectives and enhances the flexibility and clarity of header management.
src/config/server.rs (1)
  • 163-171: The refactoring of the Server struct to utilize the new headers.custom structure for managing custom headers is correctly implemented. This change ensures that the handling of response headers aligns with the updated configuration, enhancing clarity and maintainability.
generated/.tailcallrc.graphql (1)
  • 574-579: The introduction of the custom directive for handling key-value pairs in server responses, along with the update to the cacheControl input, correctly implements the proposed refactor. These changes enhance the clarity and flexibility of header management, aligning with the PR objectives.
generated/.tailcallrc.schema.json (1)
  • 1218-1227: The addition of the custom field under server.headers is aligned with the PR's objectives to streamline the configuration of custom headers in server responses. This change makes the schema more intuitive and organized, facilitating easier management of custom headers. The structure and type definitions appear to be correctly implemented, ensuring that custom headers can be defined as key-value pairs.

One thing to consider is ensuring that all existing configurations and documentation that previously used responseHeaders are updated to reflect this change. This includes updating any examples, guides, or external documentation that reference the old configuration.

@neo773 neo773 closed this Mar 12, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ffd1046 and 791cf8b.
Files selected for processing (4)
  • tests/execution/custom-headers.md (1 hunks)
  • tests/execution/test-response-header-value.md (1 hunks)
  • tests/execution/test-response-headers-multi.md (1 hunks)
  • tests/execution/test-response-headers-name.md (1 hunks)
Additional comments: 4
tests/execution/test-response-headers-name.md (1)
  • 6-6: The schema declaration correctly transitions from responseHeaders to headers with a custom field, aligning with the PR's objectives. Using emojis as keys is unconventional but acceptable if it fits your use case. Ensure consistent usage across your application.
tests/execution/test-response-header-value.md (1)
  • 6-6: The schema declaration correctly implements the transition to headers with a custom field. Including newline characters (\n) in header values is unusual and should be validated to ensure it behaves as expected in server responses.
tests/execution/test-response-headers-multi.md (1)
  • 6-6: The schema declaration correctly supports multiple custom headers. Caution: using spaces in header keys ("a b", "a c") is unconventional and might not be universally supported. Verify compatibility with your server and client implementations.
tests/execution/custom-headers.md (1)
  • 6-17: The JSON configuration correctly transitions from "responseHeaders" to "headers" with a nested "custom" array, aligning with the PR's objectives. The structure and key-value pairs for custom headers are correctly formatted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 Bounty claim type: chore Routine tasks like conversions, reorganization, and maintenance work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

move server.responseHeaders to server.headers.custom
1 participant