📒 doc: fix keyauth extractor examples#4409
Conversation
WalkthroughDocumentation examples for KeyAuth cookie-based extraction were updated to import ChangesKeyAuth Documentation Examples
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/middleware/keyauth.md`:
- Line 184: The example under "Apply middleware in the handler" imports the
unused symbol `extractors` from "github.com/gofiber/fiber/v3/extractors"; remove
that import entry so the Go snippet no longer includes `extractors` and remains
lint-clean, leaving the other imports and the example code unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b883bbeb-2545-47b0-b630-75528b54d2a3
📒 Files selected for processing (1)
docs/middleware/keyauth.md
sixcolors
left a comment
There was a problem hiding this comment.
Bot comment about default not requiring import is correct otherwise LGTM
|
Good catch — thanks @sixcolors / CodeRabbit. The third example ("Apply middleware in the handler") uses the default extractor and doesn't reference |
|
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 |
Description
The KeyAuth middleware docs (
docs/middleware/keyauth.md) have three runnablepackage mainexamples, and all three fail to compile as written:keyauth.FromCookie("access_token")— butFromCookiedoes not exist in thekeyauthpackage.go vetreportsundefined: keyauth.FromCookie.extractors.FromCookie(...)from the sharedgithub.com/gofiber/fiber/v3/extractorspackage — and the first two examples never import that package.In Fiber v3 the extractor helpers live in the shared
extractorspackage (thekeyauthpackage itself imports it and defaults toextractors.FromAuthHeader). The page's own Config table already says to useextractors.FromCookie(...)from "the shared extractors package", so the early examples were just internally inconsistent.Fix
"github.com/gofiber/fiber/v3/extractors"import to the example import blocks.keyauth.FromCookie(...)withextractors.FromCookie(...)in the two affected examples.After the change all three examples compile (
go vetpasses; the originals failed). Docs-only.