Skip to content

Improve proxy middleware#3468

Merged
ReneWerner87 merged 1 commit intomainfrom
proxy_tls_config
May 23, 2025
Merged

Improve proxy middleware#3468
ReneWerner87 merged 1 commit intomainfrom
proxy_tls_config

Conversation

@ReneWerner87
Copy link
Member

@ReneWerner87 ReneWerner87 commented May 23, 2025

Proxy Middleware Improvements

This PR enhances the proxy middleware in Fiber v3 by improving API consistency and adhering to Go naming conventions:

Key Changes

  • Renamed TlsConfig to TLSConfig in the Config struct to follow proper Go naming conventions for acronyms
  • Removed the WithTlsConfig method in favor of configuring TLS directly via the TLSConfig property or using the WithClient method
  • Updated all code references, comments, and tests to use the new property name
  • Added a comprehensive migration guide in the "What's New" documentation to help users transition from v2 to v3

Migration Example

Before (v2):

proxy.WithTlsConfig(&tls.Config{
    InsecureSkipVerify: true,
})

After (v3):

proxy.WithClient(&fasthttp.Client{
    TLSConfig: &tls.Config{InsecureSkipVerify: true},
})

These changes are part of the broader effort to standardize APIs across the Fiber framework for v3, making the codebase more consistent and maintainable.

@ReneWerner87 ReneWerner87 added this to the v3 milestone May 23, 2025
@ReneWerner87 ReneWerner87 requested a review from a team as a code owner May 23, 2025 08:35
@ReneWerner87 ReneWerner87 added this to v3 May 23, 2025
@ReneWerner87 ReneWerner87 requested a review from gaby May 23, 2025 08:35
@ReneWerner87 ReneWerner87 requested review from efectn and sixcolors May 23, 2025 08:35
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 23, 2025

Walkthrough

This update standardizes the capitalization of the TLSConfig field in the Fiber proxy middleware's configuration, replacing all instances of TlsConfig with TLSConfig in both code and documentation. Related comments and usage examples were updated accordingly, and documentation for several middleware components was revised for clarity and accuracy.

Changes

File(s) Change Summary
docs/middleware/proxy.md, docs/whats_new.md Updated documentation to use TLSConfig instead of TlsConfig, revised middleware usage examples, and clarified changes.
middleware/proxy/config.go Renamed struct field TlsConfig to TLSConfig in the Config struct and updated related comments.
middleware/proxy/proxy.go Updated comments in the Balancer function to reference TLSConfig instead of TlsConfig.
middleware/proxy/proxy_test.go Corrected test field name from TlsConfig to TLSConfig in balancer configuration.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FiberApp
    participant ProxyMiddleware

    User->>FiberApp: Sends request
    FiberApp->>ProxyMiddleware: Forwards request
    ProxyMiddleware->>ProxyMiddleware: Uses Config.TLSConfig for TLS setup
    ProxyMiddleware->>FiberApp: Returns proxied response
    FiberApp->>User: Sends response
Loading

Suggested labels

📒 Documentation

Suggested reviewers

  • efectn
  • sixcolors

Poem

In fields of Fiber, configs align,
TLS now shines with a capital sign.
Docs and tests, all tidy and neat,
Proxy middleware skips no beat!
With every hop and every hop,
This rabbit’s code just won’t stop! 🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18ed68b and aad5f94.

📒 Files selected for processing (5)
  • docs/middleware/proxy.md (2 hunks)
  • docs/whats_new.md (5 hunks)
  • middleware/proxy/config.go (1 hunks)
  • middleware/proxy/proxy.go (2 hunks)
  • middleware/proxy/proxy_test.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Compare
  • GitHub Check: repeated
  • GitHub Check: unit (1.24.x, windows-latest)
  • GitHub Check: unit (1.23.x, windows-latest)
  • GitHub Check: unit (1.23.x, macos-13)
  • GitHub Check: Analyse
🔇 Additional comments (16)
middleware/proxy/config.go (2)

29-29: Follow Go naming conventions.
Renamed the TlsConfig field to TLSConfig for proper acronym capitalization.


32-32: Update documentation comment.
Comment now correctly references TLSConfig instead of the old TlsConfig to maintain consistency.

middleware/proxy/proxy_test.go (1)

180-180: Align test with updated config field.
Updated TlsConfig to TLSConfig in test setup, ensuring the test uses the renamed field correctly.

middleware/proxy/proxy.go (2)

23-23: Update comment to include TLSConfig.
Adjusted the load balancer setup comment to reference TLSConfig instead of the old TlsConfig.


47-47: Use renamed TLSConfig field.
Correctly assigns config.TLSConfig to each HostClient, replacing the previous TlsConfig.

docs/middleware/proxy.md (2)

50-53: Reflect field rename in example.
Updated the example to configure TLS by setting the TLSConfig field directly on the client, aligning with the new API.


166-166: Fix property name in config table.
Changed TlsConfig to TLSConfig in the Config properties table to match the renamed struct field.

docs/whats_new.md (9)

39-42: Add Proxy section to What's New TOC.
Updated the table of contents to include the new Proxy middleware section alongside Logger, Monitor, and Session.


992-993: Document removal of Filesystem middleware.
Removed the Filesystem middleware section to reflect consolidation into Static middleware.


995-995: Clarify Static middleware consolidation.
Added note that Static middleware now covers Filesystem functionality, guiding users to the appropriate documentation.


997-997: Introduce enhanced Healthcheck section.
Added a new Healthcheck heading to highlight the updated middleware features.


999-999: Describe Healthcheck enhancements.
Outlined the new multi-route support and default endpoints for liveness, readiness, and startup checks.


1265-1265: Add Proxy to migration guide.
Included the Proxy section in the migration guide table of contents for v3 changes.


1864-1867: Document Proxy migration.
Added a Proxy section explaining the removal of WithTlsConfig and the introduction of the TLSConfig field in the middleware config for v3.


1871-1874: Show v2 usage of WithTlsConfig.
Included example of the old proxy configuration using proxy.WithTlsConfig, clarifying what to replace.


1882-1884: Show v3 usage with TLSConfig.
Provided example of the new configuration using TLSConfig on the client, illustrating the migration.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ReneWerner87
Copy link
Member Author

@coderabbitai add a good summary summarizing the adjustments

@codecov
Copy link

codecov bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.45%. Comparing base (18ed68b) to head (aad5f94).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3468   +/-   ##
=======================================
  Coverage   84.45%   84.45%           
=======================================
  Files         120      120           
  Lines       12157    12157           
=======================================
  Hits        10267    10267           
  Misses       1462     1462           
  Partials      428      428           
Flag Coverage Δ
unittests 84.45% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 23, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch PR details
gh pr view 3468 --json title,body,baseRefName,headRefName,additions,deletions

# Get the diff to understand the changes
git diff 18ed68b5431ac923b3f45006ce8c7600443ea560 aad5f94ad2dfecdc53a2da25b55b5e91c8082e8f

Length of output: 13629


@ReneWerner87 Here's a summary of the adjustments to the proxy middleware:

Proxy Middleware Improvements

This PR enhances the proxy middleware in Fiber v3 by improving API consistency and adhering to Go naming conventions:

Key Changes

  • Renamed TlsConfig to TLSConfig in the Config struct to follow proper Go naming conventions for acronyms
  • Removed the WithTlsConfig method in favor of configuring TLS directly via the TLSConfig property or using the WithClient method
  • Updated all code references, comments, and tests to use the new property name
  • Added a comprehensive migration guide in the "What's New" documentation to help users transition from v2 to v3

Migration Example

Before (v2):

proxy.WithTlsConfig(&tls.Config{
    InsecureSkipVerify: true,
})

After (v3):

proxy.WithClient(&fasthttp.Client{
    TLSConfig: &tls.Config{InsecureSkipVerify: true},
})

These changes are part of the broader effort to standardize APIs across the Fiber framework for v3, making the codebase more consistent and maintainable.

@ReneWerner87 ReneWerner87 merged commit aae8892 into main May 23, 2025
18 of 19 checks passed
@github-project-automation github-project-automation bot moved this to Done in v3 May 23, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: aad5f94 Previous: 18ed68b Ratio
Benchmark_Compress_Levels/Brotli_LevelBestCompression - B/op 5 B/op 0 B/op +∞

This comment was automatically generated by workflow using github-action-benchmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant