-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
WalkthroughThe 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
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 handlerThis 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: ... | Convertshttp.Handler
tofiber.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: ... | Convertshttp.Handler
tofiber.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| Converts
http.Handlermiddleware to
fiber.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: ...| Convertshttp.Handler
middleware tofiber.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: ... | Convertsfiber.Handler
tohttp.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: ... | Convertsfiber.Handler
tohttp.Handler
| | `FiberHandle...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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 | Converts
http.Handlermiddleware to
fiber.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 andnet/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 tonet/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 anet/http
handler into a Fiber handler is clear and practical. The sample usage ofadaptor.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 ofadaptor.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 bothhttp.Handler
andhttp.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 usingadaptor.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 usingadaptor.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 indocs/middleware/adaptor.md
.
There was a problem hiding this 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
There was a problem hiding this 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 SectionThe 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 tonet/http
handlers. - Convert Fiber context (fiber.Ctx
) into an `ht...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
15-27
: Well-Formatted API Reference with Minor Stylistic ConsiderationsThe 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: ... | Convertshttp.Handler
tofiber.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: ... | Convertshttp.Handler
tofiber.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| Converts
http.Handlermiddleware to
fiber.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: ...| Convertshttp.Handler
middleware tofiber.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: ... | Convertsfiber.Handler
tohttp.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: ... | Convertsfiber.Handler
tohttp.Handler
| | `FiberHandle...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
138-144
: Usage Example 4 – Running a Fiber App within an http.ServerThe 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 CapabilitiesThe 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
📒 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 | Converts
http.Handlermiddleware to
fiber.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 ClarificationThe updated description now clearly states that the
adaptor
package provides utilities for converting between Fiber andnet/http
, emphasizing seamless integration in both directions. This added clarity is very helpful for new users.
30-31
: Valuable Addition of Usage Examples SectionThe 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 HandlersThe example clearly demonstrates converting a standard
http.Handler
into a Fiber handler. Both the inline comment and the code (usingadaptor.HTTPHandler
) effectively illustrate the intended usage. ThehelloHandler
function is straightforward and well documented.
77-91
: Usage Example 2 – Integrating net/http MiddlewareThe 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 HandlersThis example cleanly illustrates how to convert a Fiber handler into both an
http.Handler
and anhttp.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.RequestThis 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #3311