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: Improve ctx.Locals method description, godoc and example #3032

Merged
merged 6 commits into from
Jun 18, 2024

Conversation

sixcolors
Copy link
Member

@sixcolors sixcolors commented Jun 11, 2024

Description

Improve the ctx.Locals documentation to clarify the behavior of stored variables and their lifecycle to avoid unintentional resource closures, and provide best practices with keys and values.

Changes Introduced

  • Documentation Update:
    • Added a clarification that stored variables are removed after the request is handled.
    • Specified that if any stored data implements the io.Closer interface, its Close method will be called before it's removed.
  • Example Code Enhancement:
    • Demonstrated the use of a non-exported type as a key to avoid collisions.
    • Included type assertions when retrieving stored data to ensure it is of the expected type.

Details

  • Files Modified: docs/api/ctx.md and ctx.go
  • Benchmark Impact: None
  • Documentation Updates: Improved clarity and provided best practices in the Locals method documentation.
  • Changelog Entries:
    • Clarified behavior of ctx.Locals regarding variable removal and io.Closer interface handling.
    • Updated example code to illustrate best practices for key usage and type assertions.
  • Migration Guide: Not applicable

These changes aim to prevent issues with unintentional resource closures, such as database connections, and enhance the clarity and safety of using ctx.Locals in fiber.

@sixcolors sixcolors requested a review from a team as a code owner June 11, 2024 18:51
@sixcolors sixcolors requested review from gaby, ReneWerner87 and efectn and removed request for a team June 11, 2024 18:51
Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

The changes enhance the Locals method in various fiber.Ctx structures in Go programming, providing documentation on how these contexts handle the removal of values after request handling and how they call the Close method on values implementing the io.Closer interface before removal. This ensures that resources are properly managed and released after use, preventing potential memory leaks and improving overall efficiency in handling web requests.

Changes

Files Change Summaries
ctx.go Added documentation to DefaultCtx's Locals function about removal of values and Close method calls.
docs/api/ctx.md Updated documentation for Locals method and related types in fiber.Ctx structure to reflect new behavior.
ctx_interface_gen.go Augmented Ctx interface's Locals method to include documentation on value removal and Close method calls.

Poem

In fields of code where fibers weave,
A rabbit hopped with code to leave.
Each context clean, each close secure,
Memory leaks? No need to fear.
With keys well-typed, the pathways clear,
In requests we trust, no burdens bear.


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 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 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 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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.
  • 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

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.78%. Comparing base (9caa11f) to head (8419c3c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3032      +/-   ##
==========================================
- Coverage   82.86%   82.78%   -0.08%     
==========================================
  Files         115      115              
  Lines        8227     8227              
==========================================
- Hits         6817     6811       -6     
- Misses       1082     1086       +4     
- Partials      328      330       +2     
Flag Coverage Δ
unittests 82.78% <ø> (-0.08%) ⬇️

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.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 46fffe4 and cc3dd43.

Files selected for processing (2)
  • ctx.go (2 hunks)
  • docs/api/ctx.md (2 hunks)
Additional context used
LanguageTool
docs/api/ctx.md

[uncategorized] ~223-~223: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...urns a pointer to the Bind struct which contains all the methods to bind ...


[uncategorized] ~225-~225: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...he request/response data. For detailed information check the Bind documentati...


[uncategorized] ~257-~257: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...// []byte("user=john") }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~281-~281: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...// []byte("user=john") }) ``` :::info Returned value is only valid within the handler....


[style] ~341-~341: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ... information from a ClientHello message in order to guide application logic in the GetCerti...


[typographical] ~364-~364: Consider adding a comma here. (PLEASE_COMMA)
Context: ...text() *fasthttp.RequestCtx ``` :::info Please read the [Fasthttp Documentation](https...


[uncategorized] ~423-~423: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...oe") // "doe" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~541-~541: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ... if not exist // .. }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~549-~549: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE_2)
Context: ...icate that the client cache is now stale and the full response should be sent. When...


[uncategorized] ~581-~581: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...n") // "john" // .. }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~596-~596: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...ers() map[string][]string ``` :::info Returned value is only valid within the handler....


[uncategorized] ~624-~624: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...n") // "john" // .. }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~639-~639: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...ers() map[string][]string ``` :::info Returned value is only valid within the handler....


[uncategorized] ~692-~692: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ..."google.com" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~717-~717: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ..."google.com" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~1129-~1129: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...q=something" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~1182-~1182: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...first wildcard segment }) ``` :::info Returned value is only valid within the handler....


[grammar] ~1275-~1275: Did you mean “are” or “were”? (SENT_START_NNS_IS)
Context: ..." // ... }) ``` ## Queries Queries is a function that returns an object conta...


[uncategorized] ~1362-~1362: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...") // "nike" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~1430-~1430: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...s the Redirect reference. For detailed information check the Redirect doc...


[uncategorized] ~1449-~1449: Did you mean: “By default,”? (BY_DEFAULT_COMMA)
Context: ... data and sends a text/html response. By default Render uses the default [**Go Templat...


[style] ~1449-~1449: To make your writing clearer, consider a more direct alternative. (TAKE_A_LOOK)
Context: ...want to use another View engine, please take a look at our [Template middleware](h...


[grammar] ~1457-~1457: Please check the verb form. (SHE_LIVE)
Context: ....string) error ``` ## Request Request return the [*fasthttp.Request](https://godoc....


[style] ~1457-~1457: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym. (ENGLISH_WORD_REPEAT_BEGINNING_RULE)
Context: ...Request Request return the [*fasthttp.Request](https://godoc.org/github.com/valyala/f...


[grammar] ~1472-~1472: Please check the verb form. (SHE_LIVE)
Context: ...te("GET") }) ``` ## Response Response return the [*fasthttp.Response](https://godoc...


[style] ~1472-~1472: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym. (ENGLISH_WORD_REPEAT_BEGINNING_RULE)
Context: ...sponse Response return the [*fasthttp.Response](https://godoc.org/github.com/valyala/f...


[style] ~1494-~1494: This phrase is redundant. Consider using “outside”. (OUTSIDE_OF)
Context: ...x *fasthttp.RequestCtx) ``` It is used outside of the Fiber Handlers to reset the context...


[uncategorized] ~1498-~1498: There should be no space here. (EG_SPACE)
Context: ...y be helpful after overriding the path, i. e. an internal redirect. Note that handler...


[uncategorized] ~1498-~1498: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...t. Note that handlers might be executed again which could result in an infinite loop....


[uncategorized] ~1552-~1552: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ... return err } } ``` ## SaveFile Method is used to save any multipart file ...


[typographical] ~1623-~1623: Consider adding a comma here. (PLEASE_COMMA)
Context: ...http or https for TLS requests. :::info Please use [Config.EnableTrustedProxyCheck](...

Markdownlint
docs/api/ctx.md

983-983: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1005-1005: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1189-1189: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1190-1190: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1368-1368: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1369-1369: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1392-1392: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1393-1393: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1394-1394: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1285-1285: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1286-1286: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1287-1287: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1288-1288: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1289-1289: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1297-1297: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1298-1298: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1299-1299: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1307-1307: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1308-1308: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1309-1309: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1310-1310: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1318-1318: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1319-1319: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1320-1320: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1328-1328: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1329-1329: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1330-1330: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1331-1331: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1332-1332: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1333-1333: Column: 1 (MD010, no-hard-tabs)
Hard tabs


168-168: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


1188-1188: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


1216-1216: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


1446-1446: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


1209-1209: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


1398-1398: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines

Additional comments not posted (3)
docs/api/ctx.md (2)

948-951: The updated documentation for the Locals method is clear and informative.

It effectively explains the scope and lifecycle of stored variables, including the automatic removal and closure of resources implementing io.Closer. The tip about using non-exported types as keys to avoid collisions is a valuable addition for best practices.


962-962: The example code effectively demonstrates the use of non-exported types as keys and type assertions.

This is a practical example that not only shows how to use the Locals method but also reinforces the documentation on preventing key collisions and ensuring type safety.

Also applies to: 969-976

ctx.go (1)

Line range hint 862-880: Clarify the behavior of Locals methods regarding io.Closer.

The documentation added to the Locals methods clearly explains the lifecycle of stored values, including the automatic removal and the invocation of the Close method for values implementing io.Closer. This is a crucial detail for proper resource management and helps prevent resource leaks.

@sixcolors sixcolors added the v3 label Jun 11, 2024
@ReneWerner87
Copy link
Member

ReneWerner87 commented Jun 12, 2024

  • pls regenerate the interface - see here - use go generate

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cc3dd43 and 7e83239.

Files selected for processing (1)
  • docs/api/ctx.md (2 hunks)
Additional context used
LanguageTool
docs/api/ctx.md

[uncategorized] ~225-~225: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...he request/response data. For detailed information check the Bind documentati...


[uncategorized] ~257-~257: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...// []byte("user=john") }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~281-~281: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...// []byte("user=john") }) ``` :::info Returned value is only valid within the handler....


[style] ~341-~341: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ... information from a ClientHello message in order to guide application logic in the GetCerti...


[typographical] ~364-~364: Consider adding a comma here. (PLEASE_COMMA)
Context: ...text() *fasthttp.RequestCtx ``` :::info Please read the [Fasthttp Documentation](https...


[uncategorized] ~423-~423: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...oe") // "doe" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~541-~541: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ... if not exist // .. }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~549-~549: Use a comma before “and” if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE_2)
Context: ...icate that the client cache is now stale and the full response should be sent. When...


[uncategorized] ~581-~581: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...n") // "john" // .. }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~596-~596: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...ers() map[string][]string ``` :::info Returned value is only valid within the handler....


[uncategorized] ~624-~624: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...n") // "john" // .. }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~639-~639: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...ers() map[string][]string ``` :::info Returned value is only valid within the handler....


[uncategorized] ~692-~692: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ..."google.com" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~717-~717: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ..."google.com" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~1129-~1129: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...q=something" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~1136-~1136: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...](../#zero-allocation) ::: ## Params Method can be used to get the route parameters...


[uncategorized] ~1182-~1182: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...first wildcard segment }) ``` :::info Returned value is only valid within the handler....


[grammar] ~1275-~1275: Did you mean “are” or “were”? (SENT_START_NNS_IS)
Context: ..." // ... }) ``` ## Queries Queries is a function that returns an object conta...


[uncategorized] ~1362-~1362: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...") // "nike" // ... }) ``` :::info Returned value is only valid within the handler....


[uncategorized] ~1430-~1430: Possible missing comma found. (AI_HYDRA_LEO_MISSING_COMMA)
Context: ...s the Redirect reference. For detailed information check the Redirect doc...


[uncategorized] ~1449-~1449: Did you mean: “By default,”? (BY_DEFAULT_COMMA)
Context: ... data and sends a text/html response. By default Render uses the default [**Go Templat...


[style] ~1449-~1449: To make your writing clearer, consider a more direct alternative. (TAKE_A_LOOK)
Context: ...want to use another View engine, please take a look at our [Template middleware](h...


[grammar] ~1457-~1457: Please check the verb form. (SHE_LIVE)
Context: ....string) error ``` ## Request Request return the [*fasthttp.Request](https://godoc....


[style] ~1457-~1457: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym. (ENGLISH_WORD_REPEAT_BEGINNING_RULE)
Context: ...Request Request return the [*fasthttp.Request](https://godoc.org/github.com/valyala/f...


[grammar] ~1472-~1472: Please check the verb form. (SHE_LIVE)
Context: ...te("GET") }) ``` ## Response Response return the [*fasthttp.Response](https://godoc...


[style] ~1472-~1472: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym. (ENGLISH_WORD_REPEAT_BEGINNING_RULE)
Context: ...sponse Response return the [*fasthttp.Response](https://godoc.org/github.com/valyala/f...


[style] ~1494-~1494: This phrase is redundant. Consider using “outside”. (OUTSIDE_OF)
Context: ...x *fasthttp.RequestCtx) ``` It is used outside of the Fiber Handlers to reset the context...


[uncategorized] ~1498-~1498: There should be no space here. (EG_SPACE)
Context: ...y be helpful after overriding the path, i. e. an internal redirect. Note that handler...


[uncategorized] ~1585-~1585: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...n err } }) ``` ## SaveFileToStorage Method is used to save any multipart file ...


[typographical] ~1623-~1623: Consider adding a comma here. (PLEASE_COMMA)
Context: ...http or https for TLS requests. :::info Please use [Config.EnableTrustedProxyCheck](...

Markdownlint
docs/api/ctx.md

983-983: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1005-1005: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1189-1189: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1190-1190: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1368-1368: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1369-1369: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1392-1392: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1393-1393: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1394-1394: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


1285-1285: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1286-1286: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1287-1287: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1288-1288: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1289-1289: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1297-1297: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1298-1298: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1299-1299: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1307-1307: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1308-1308: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1309-1309: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1310-1310: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1318-1318: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1319-1319: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1320-1320: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1328-1328: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1329-1329: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1330-1330: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1331-1331: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1332-1332: Column: 1 (MD010, no-hard-tabs)
Hard tabs


1333-1333: Column: 1 (MD010, no-hard-tabs)
Hard tabs


168-168: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


1188-1188: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


1216-1216: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


1446-1446: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


1209-1209: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


1398-1398: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines

Additional comments not posted (2)
docs/api/ctx.md (2)

948-951: Enhanced documentation for ctx.Locals clarifies lifecycle and type safety.

The updated documentation clearly explains the lifecycle of stored variables and the importance of type assertions, which improves the understanding and correct usage of the ctx.Locals method.


960-960: Updated example code demonstrates best practices for handling keys and type assertions.

The example code effectively demonstrates the use of non-exported types for keys to avoid collisions and the proper way to perform type assertions. This is a valuable update for preventing common errors and ensuring data integrity.

Also applies to: 962-962, 967-967, 970-970, 975-976

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7e83239 and 8419c3c.

Files selected for processing (1)
  • ctx_interface_gen.go (1 hunks)
Additional comments not posted (1)
ctx_interface_gen.go (1)

177-180: The documentation added to the Locals method clearly explains the lifecycle of stored values and their cleanup process. However, consider a slight grammatical adjustment for clarity.

- // All the values are removed from ctx after returning from the top
- // RequestHandler. Additionally, Close method is called on each value
- // implementing io.Closer before removing the value from ctx.
+ // All values are removed from ctx after returning from the top
+ // RequestHandler. Additionally, the Close method is called on each value
+ // that implements io.Closer before the value is removed from ctx.

@ReneWerner87 ReneWerner87 merged commit 011e83b into main Jun 18, 2024
14 of 15 checks passed
@efectn efectn deleted the docs-ctx-locals branch June 28, 2024 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants