Skip to content

📒 docs: Update usage of ctx.Redirect() #3417

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

Merged
merged 3 commits into from
Apr 26, 2025
Merged

Conversation

andradei
Copy link
Contributor

Description

Update documentation of Ctx.Redirect in v2 branch after solutions decided in #3405.

Closes #3405

@andradei andradei requested a review from a team as a code owner April 19, 2025 00:57
Copy link
Contributor

coderabbitai bot commented Apr 19, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • .github/workflows/linter.yml is excluded by !**/*.yml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This change updates the docs/api/ctx.md documentation to standardize the formatting of informational notes by replacing blockquotes starting with a hyphen (->) with the markdown blockquote symbol (>). It also adds a new caution note to the Redirect method section, explaining that HTTP status code 302 may cause browsers to change the HTTP method during redirects and advising the use of status codes 303, 307, or 308 to preserve the original method. An example usage is included. Minor whitespace cleanups were also performed. No changes were made to any code or exported/public APIs.

Changes

File(s) Change Summary
docs/api/ctx.md Standardized blockquote formatting for notes; added caution note and example to the Redirect method documentation about HTTP method changes on 302; minor whitespace cleanup.

Sequence Diagram(s)

No sequence diagram is generated as the changes are documentation-only.

Assessment against linked issues

Objective Addressed Explanation
c.Redirect should respect c.Method and override the HTTP method for the redirected request (#3405) The changes are documentation-only and do not address the bug or implement a code solution.

Possibly related PRs

Suggested labels

📒 Documentation

Suggested reviewers

  • gaby
  • sixcolors
  • ReneWerner87

Poem

In docs where notes once hid away,
The rabbit hopped and cleared the way.
With blockquotes neat and warnings bright,
Redirects explained in clearer light.
No code was touched, just words made right—
Now readers hop through docs with delight!
🐇📚✨


🪧 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.
  • @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.

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: 1

🧹 Nitpick comments (1)
docs/api/ctx.md (1)

1450-1459: Enhance readability of status code list
Consider wrapping the HTTP status codes in inline code for clarity within the caution block:

- - 303 See Other
- - 307 Temporary Redirect
- - 308 Permanent Redirect
+ - `303 See Other`
+ - `307 Temporary Redirect`
+ - `308 Permanent Redirect`
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cf5041b and 670580b.

📒 Files selected for processing (1)
  • docs/api/ctx.md (17 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/api/ctx.md

[uncategorized] ~242-~242: Possible missing article found.
Context: ...aw()) // []byte("user=john") }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~262-~262: Possible missing article found.
Context: ...dy()) // []byte("user=john") }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~322-~322: Possible missing article found.
Context: ...lhost:3000/?name=john&pass=doe" ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~492-~492: Possible missing article found.
Context: ...y", "doe") // "doe" // ... }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~582-~582: Possible missing article found.
Context: ... or "" if not exist // .. }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~618-~618: Possible missing article found.
Context: ..., "john") // "john" // .. }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~629-~629: Possible missing article found.
Context: ...eqHeaders() map[string][]string ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~653-~653: Possible missing article found.
Context: ..., "john") // "john" // .. }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~664-~664: Possible missing article found.
Context: ...spHeaders() map[string][]string ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~710-~710: Possible missing article found.
Context: ...() // "google.com" // ... }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~1057-~1057: Possible missing article found.
Context: ...earch?q=something" // ... }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~1106-~1106: Possible missing article found.
Context: ...f the first wildcard segment }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~1283-~1283: Possible missing article found.
Context: ... "nike") // "nike" // ... }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)

🔇 Additional comments (1)
docs/api/ctx.md (1)

242-243: Consistent admonition formatting across methods
The blockquotes have been updated from hyphen (->) style to standard Markdown > syntax, improving consistency and rendering across sections. Nice work!

Also applies to: 262-263, 322-323, 492-493, 582-583, 618-619, 629-630, 653-654, 664-665, 710-711, 1057-1058, 1106-1107, 1283-1284

🧰 Tools
🪛 LanguageTool

[uncategorized] ~242-~242: Possible missing article found.
Context: ...aw()) // []byte("user=john") }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)

@gaby
Copy link
Member

gaby commented Apr 19, 2025

@andradei We don't need this PR. In the main branch under `docs/whats_new.md" It should go there.

Document the change in #3415

@gaby gaby closed this Apr 19, 2025
@andradei
Copy link
Contributor Author

@gaby what about people that are still using v2 and reading the v2 documentation? This change would've saved me several minutes debugging this peculiar behavior.

@gaby
Copy link
Member

gaby commented Apr 20, 2025

@gaby what about people that are still using v2 and reading the v2 documentation? This change would've saved me several minutes debugging this peculiar behavior.

That's why we added What's New for v3. It's a major release, so breaking changes are expected.

@gaby gaby reopened this Apr 20, 2025
@gaby gaby added the v2 label Apr 20, 2025
@gaby gaby changed the title 📚 Improve docs for Ctx.Redirect 📒 docs: Update usage of ctx.Redirect() Apr 20, 2025
@gaby
Copy link
Member

gaby commented Apr 22, 2025

@andradei Let me know if that makes sense

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

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

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/api/ctx.md (1)

242-243: Suggest adding missing article for clarity
Each of these note blocks would read more naturally with an initial "The". For example, change:

> _Returned value is only valid within the handler. Do not store any references._

to:

> _The returned value is only valid within the handler. Do not store any references._

This small tweak improves readability and grammatical correctness.

Also applies to: 262-263, 322-323, 492-493, 582-583, 618-619, 629-630, 653-654, 664-665, 710-711, 1057-1058, 1106-1107, 1283-1284

🧰 Tools
🪛 LanguageTool

[uncategorized] ~242-~242: Possible missing article found.
Context: ...aw()) // []byte("user=john") }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 670580b and 73b31ba.

📒 Files selected for processing (1)
  • docs/api/ctx.md (17 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/api/ctx.md

[uncategorized] ~242-~242: Possible missing article found.
Context: ...aw()) // []byte("user=john") }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~262-~262: Possible missing article found.
Context: ...dy()) // []byte("user=john") }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~322-~322: Possible missing article found.
Context: ...lhost:3000/?name=john&pass=doe" ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~492-~492: Possible missing article found.
Context: ...y", "doe") // "doe" // ... }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~582-~582: Possible missing article found.
Context: ... or "" if not exist // .. }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~618-~618: Possible missing article found.
Context: ..., "john") // "john" // .. }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~629-~629: Possible missing article found.
Context: ...eqHeaders() map[string][]string ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~653-~653: Possible missing article found.
Context: ..., "john") // "john" // .. }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~664-~664: Possible missing article found.
Context: ...spHeaders() map[string][]string ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~710-~710: Possible missing article found.
Context: ...() // "google.com" // ... }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~1057-~1057: Possible missing article found.
Context: ...earch?q=something" // ... }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~1106-~1106: Possible missing article found.
Context: ...f the first wildcard segment }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~1283-~1283: Possible missing article found.
Context: ... "nike") // "nike" // ... }) ``` > _Returned value is only valid within the handler....

(AI_HYDRA_LEO_MISSING_THE)

🔇 Additional comments (2)
docs/api/ctx.md (2)

60-60: Skip trivial example change
The update on this example line is a minor formatting/whitespace adjustment and does not affect the documentation's correctness or clarity.


1447-1461: Great addition: caution on HTTP method preservation during redirects
The new :::caution block accurately warns users about browsers potentially changing POST to GET on a 302 redirect and recommends 303, 307, or 308 to preserve the original method. This enhances clarity for v2 users.

@gaby
Copy link
Member

gaby commented Apr 26, 2025

I do not understand why the CI is running.

@ReneWerner87 ReneWerner87 merged commit ac8b1c9 into gofiber:v2 Apr 26, 2025
26 of 27 checks passed
Copy link

welcome bot commented Apr 26, 2025

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@ReneWerner87 ReneWerner87 added this to the Next Release milestone May 22, 2025
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