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

docs: Update adapter middleware documentation #3317

Merged
merged 2 commits into from
Feb 20, 2025
Merged

docs: Update adapter middleware documentation #3317

merged 2 commits into from
Feb 20, 2025

Conversation

ReneWerner87
Copy link
Member

Fixes #3311

@ReneWerner87 ReneWerner87 requested a review from a team as a code owner February 20, 2025 11:59
@ReneWerner87 ReneWerner87 requested review from gaby, sixcolors and efectn and removed request for a team February 20, 2025 11:59
Copy link
Contributor

coderabbitai bot commented Feb 20, 2025

Walkthrough

The pull request updates two documentation files. In the FAQ document, capitalization errors in question titles have been fixed and additional content has been added, including a subdomain routing example in a collapsible section and a new topic on converting between Fiber and net/http. The adaptor documentation has been revised to improve clarity by restructuring the introduction, API reference, and usage examples, as well as updating method signature descriptions.

Changes

Files Change Summary
docs/extra/faq.md Corrected FAQ capitalization errors; added a detailed subdomain routing example using a <details> tag; introduced a section on Fiber/net-http conversion.
docs/middleware/adaptor.md Revised adaptor package documentation with a clearer introduction, restructured API reference and examples; updated method signature descriptions for clarity.

Suggested reviewers

  • sixcolors
  • gaby
  • efectn

Poem

I'm a bunny in the docs, hopping through each line,
Fixing caps and spelling, making everything shine.
Examples and adapters, all neatly re-arranged,
In a world of code and clarity, my joy is not estranged.
Hop along with me—let’s celebrate these changes divine!


🪧 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.
    • Generate unit testing code 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 testing code 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 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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/middleware/adaptor.md (1)

17-29: API Reference Table – Vary the Sentence Beginnings
The API reference table is comprehensive and easy to read. However, most descriptions begin with "Converts," which makes the text feel repetitive. Consider varying the language to improve readability. For example:

-| `HTTPHandler`               | `HTTPHandler(h http.Handler) fiber.Handler`  | Converts `http.Handler` to `fiber.Handler`
+| `HTTPHandler`               | `HTTPHandler(h http.Handler) fiber.Handler`  | Transforms a standard `http.Handler` into a Fiber handler

This variation can be applied to other rows as well.

🧰 Tools
🪛 LanguageTool

[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler | | `HTTPHandler...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~23-~23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | | HTTPMiddleware | HTTPMiddleware(mw func(http.Handler) http.Handler) fiber.Handler | Converts `...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~23-~23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...r) fiber.Handler | Convertshttp.Handlermiddleware tofiber.Handler` middlewa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~23-~23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~24-~24: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...eware | | FiberHandler | FiberHandler(h fiber.Handler) http.Handler | Con...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~24-~24: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~24-~24: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 283ef32 and cdb862a.

📒 Files selected for processing (2)
  • docs/extra/faq.md (3 hunks)
  • docs/middleware/adaptor.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/middleware/adaptor.md

[style] ~15-~15: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...iber handlers to net/http handlers. - Convert Fiber context (fiber.Ctx) into an `ht...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler | | `HTTPHandler...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~23-~23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | | HTTPMiddleware | HTTPMiddleware(mw func(http.Handler) http.Handler) fiber.Handler | Converts `...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~23-~23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...r) fiber.Handler | Convertshttp.Handlermiddleware tofiber.Handler` middlewa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~23-~23: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~24-~24: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...eware | | FiberHandler | FiberHandler(h fiber.Handler) http.Handler | Con...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~24-~24: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~24-~24: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (11)
docs/middleware/adaptor.md (8)

7-9: Clear Introduction and Acknowledgement
The updated introduction now clearly explains that the adaptor package provides utilities for converting between Fiber and net/http. The acknowledgment to [@arsmn] adds a nice touch.


11-16: Well-Structured Features Section
The features list succinctly outlines the capabilities of the adaptor package. This clear enumeration helps users quickly understand what conversions are supported.

🧰 Tools
🪛 LanguageTool

[style] ~15-~15: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...iber handlers to net/http handlers. - Convert Fiber context (fiber.Ctx) into an `ht...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


51-60: Clear Example for Converting HTTP Handlers
The code example demonstrating the conversion of a net/http handler into a Fiber handler is clear and practical. The sample usage of adaptor.HTTPHandler effectively illustrates the intended functionality.


79-84: Solid Middleware Conversion Example
The example for applying an HTTP middleware in Fiber is well presented. The usage of adaptor.HTTPMiddleware together with a simple logging middleware clearly communicates the conversion approach.


111-116: Good Demonstration for Fiber to net/http Conversion
The snippet shows how to convert Fiber handlers into both http.Handler and http.HandlerFunc. This dual demonstration is very helpful for users needing to integrate Fiber with net/http.


140-142: Effective Example of Running a Fiber App Inside net/http
The example clearly illustrates how to wrap a Fiber app using adaptor.FiberApp. This is a practical demonstration that can help users integrate Fiber applications into existing net/http servers.


163-174: Clear Example for Converting Fiber Context to http.Request
The code snippet detailing the conversion using adaptor.ConvertRequest is straightforward and useful. The example not only demonstrates the conversion but also shows basic error handling.


179-187: Concise and Informative Summary Section
The summary neatly encapsulates the capabilities of the adaptor package, reiterating its multiple conversion functions. This serves as a good conclusion to the documentation.

docs/extra/faq.md (3)

33-37: Enhanced Live Reload Section
The "How can I use live reload?" section is a useful addition. By introducing Air with a clear explanation and a sample configuration, this section provides practical guidance on improving development workflow.


102-178: Comprehensive Subdomain Routing Example
The new subdomain routing section is very thorough. The inclusion of a collapsible <details> block with a complete Go code example makes it easy for users to understand how to set up multiple hosts. The example is well organized and demonstrates real-world usage.


179-190: Well-Integrated Conversions Section
The new FAQ section "How can I handle conversions between Fiber and net/http?" effectively links to the adaptor documentation. This cross-reference helps users who may be looking for detailed conversion examples and reinforces the improved documentation in docs/middleware/adaptor.md.

@gaby gaby changed the title add more adpater documenation docs: Update adapter middleware documentation Feb 20, 2025
Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

LGTM, just a few fixes

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.

Actionable comments posted: 0

🧹 Nitpick comments (4)
docs/middleware/adaptor.md (4)

9-13: Clear and Concise Features Section

The new "Features" section succinctly lists the core capabilities of the package. One minor suggestion is to vary the starting verbs in the bullet points (e.g., "Bridge" or "Transform" instead of repeating "Convert") to improve readability, as indicated by the static analysis hints regarding repetitive phrasing.

🧰 Tools
🪛 LanguageTool

[style] ~13-~13: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...iber handlers to net/http handlers. - Convert Fiber context (fiber.Ctx) into an `ht...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


15-27: Well-Formatted API Reference with Minor Stylistic Considerations

The API reference table is clear and provides essential details for each function. However, each description begins uniformly with "Converts," which triggers static analysis warnings for repeated sentence starts. Consider slightly rephrasing some of these entries to reduce repetition (for example, varying with "Transforms," "Maps," or "Adapts") if it aligns with your style guidelines.

🧰 Tools
🪛 LanguageTool

[style] ~19-~19: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~19-~19: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler | | `HTTPHandler...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | | HTTPMiddleware | HTTPMiddleware(mw func(http.Handler) http.Handler) fiber.Handler | Converts `...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...r) fiber.Handler | Convertshttp.Handlermiddleware tofiber.Handler` middlewa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...eware | | FiberHandler | FiberHandler(h fiber.Handler) http.Handler | Con...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


138-144: Usage Example 4 – Running a Fiber App within an http.Server

The example does an excellent job of demonstrating how to embed a full Fiber application inside a standard net/http server. One suggestion: consider mentioning that, in production scenarios, handling errors from http.ListenAndServe is important—even though the example remains effective for illustrative purposes.


177-185: Summary Section Effectively Recaps Key Capabilities

The summary concisely reiterates the package’s main features and benefits. As with the features list, the bullet points repetitively start with similar phrasing. Consider varying the verb choices in these points for stylistic diversity, in line with the static analysis suggestions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cdb862a and d655e08.

📒 Files selected for processing (2)
  • docs/extra/faq.md (3 hunks)
  • docs/middleware/adaptor.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/extra/faq.md
🧰 Additional context used
🪛 LanguageTool
docs/middleware/adaptor.md

[style] ~13-~13: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...iber handlers to net/http handlers. - Convert Fiber context (fiber.Ctx) into an `ht...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~19-~19: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~19-~19: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler | | `HTTPHandler...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | | HTTPMiddleware | HTTPMiddleware(mw func(http.Handler) http.Handler) fiber.Handler | Converts `...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...r) fiber.Handler | Convertshttp.Handlermiddleware tofiber.Handler` middlewa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...eware | | FiberHandler | FiberHandler(h fiber.Handler) http.Handler | Con...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (6)
docs/middleware/adaptor.md (6)

7-7: Enhanced Package Description Clarification

The updated description now clearly states that the adaptor package provides utilities for converting between Fiber and net/http, emphasizing seamless integration in both directions. This added clarity is very helpful for new users.


30-31: Valuable Addition of Usage Examples Section

The introduction of the "Usage Examples" section offers practical, real-world scenarios on how to employ the package. This greatly enhances the documentation's usability.


49-57: Usage Example 1 – Conversion of HTTP Handlers

The example clearly demonstrates converting a standard http.Handler into a Fiber handler. Both the inline comment and the code (using adaptor.HTTPHandler) effectively illustrate the intended usage. The helloHandler function is straightforward and well documented.


77-91: Usage Example 2 – Integrating net/http Middleware

The middleware example is well constructed and shows how to apply a standard net/http middleware within a Fiber app. The inline comments enhance clarity, and the loggingMiddleware example is effective for demonstration purposes. For production-ready code, you might consider adding a note about incorporating error handling or logging enhancements.


109-120: Usage Example 3 – Converting Fiber Handlers into net/http Handlers

This example cleanly illustrates how to convert a Fiber handler into both an http.Handler and an http.HandlerFunc. The code and comments provide clear guidance, ensuring users can integrate Fiber handlers easily with net/http workflows.


162-172: Usage Example 5 – Converting fiber.Ctx to http.Request

This code snippet effectively shows how to convert a Fiber context into an http.Request, including basic error handling. It is clear and informative. A brief comment on potential error scenarios could further improve the example, but overall it meets its instructional goal well.

Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

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

LGTM

@gaby gaby merged commit 252a022 into main Feb 20, 2025
2 checks passed
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.

📝 [Proposal]: Help fasthttp convert to other
2 participants