-
-
Notifications
You must be signed in to change notification settings - Fork 486
Updates the example for a Parsley-enabled app #3137
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
base: master
Are you sure you want to change the base?
Updates the example for a Parsley-enabled app #3137
Conversation
## Walkthrough
The Parsley example's README was extensively expanded and restructured into a detailed tutorial with prerequisites, overview, stepwise instructions, and comprehensive code examples. Additionally, import paths in source files were updated to fully qualified module paths, and minor formatting improvements were made. No public APIs or exported entities were changed.
## Changes
| File(s) | Change Summary |
|----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| parsley/README.md | Expanded and restructured into a detailed tutorial with prerequisites, overview, step-by-step instructions, and example usage commands. |
| parsley/cmd/main.go | Updated import paths to fully qualified module paths; renamed context variable to `ctx` to avoid shadowing; no logic changes. |
| parsley/internal/application.go | Updated import path for `route_handlers` to fully qualified module path; no logic changes. |
| parsley/internal/modules/greeter_module.go | Updated import path for `services` to fully qualified module path; no logic changes. |
| parsley/internal/modules/route_handlers_module.go | Updated import path for `route_handlers` to fully qualified module path; no logic changes. |
| parsley/internal/route_handlers/greeter.go | Updated import path for `services` to fully qualified module path; added a blank line at start of method body; no logic changes. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant Client
participant FiberApp
participant GreeterService
Client->>FiberApp: HTTP GET /say-hello?polite=true
FiberApp->>GreeterService: Call Greet(polite)
GreeterService-->>FiberApp: Returns greeting string
FiberApp-->>Client: Respond with greeting Possibly related PRs
Suggested reviewers
Poem
|
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)
parsley/README.md (1)
1-226
: Consider using spaces instead of tabs in markdownThe static analysis tool detected hard tabs throughout the markdown file. While the content is excellent, consider using spaces instead of tabs for better markdown rendering consistency across different platforms.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
58-58: Hard tabs
Column: 1(MD010, no-hard-tabs)
60-60: Hard tabs
Column: 1(MD010, no-hard-tabs)
61-61: Hard tabs
Column: 1(MD010, no-hard-tabs)
63-63: Hard tabs
Column: 1(MD010, no-hard-tabs)
68-68: Hard tabs
Column: 1(MD010, no-hard-tabs)
70-70: Hard tabs
Column: 1(MD010, no-hard-tabs)
71-71: Hard tabs
Column: 1(MD010, no-hard-tabs)
72-72: Hard tabs
Column: 1(MD010, no-hard-tabs)
73-73: Hard tabs
Column: 1(MD010, no-hard-tabs)
90-90: Hard tabs
Column: 1(MD010, no-hard-tabs)
91-91: Hard tabs
Column: 1(MD010, no-hard-tabs)
92-92: Hard tabs
Column: 1(MD010, no-hard-tabs)
98-98: Hard tabs
Column: 1(MD010, no-hard-tabs)
99-99: Hard tabs
Column: 1(MD010, no-hard-tabs)
100-100: Hard tabs
Column: 1(MD010, no-hard-tabs)
101-101: Hard tabs
Column: 1(MD010, no-hard-tabs)
103-103: Hard tabs
Column: 1(MD010, no-hard-tabs)
104-104: Hard tabs
Column: 1(MD010, no-hard-tabs)
106-106: Hard tabs
Column: 1(MD010, no-hard-tabs)
110-110: Hard tabs
Column: 1(MD010, no-hard-tabs)
128-128: Hard tabs
Column: 1(MD010, no-hard-tabs)
134-134: Hard tabs
Column: 1(MD010, no-hard-tabs)
135-135: Hard tabs
Column: 1(MD010, no-hard-tabs)
136-136: Hard tabs
Column: 1(MD010, no-hard-tabs)
137-137: Hard tabs
Column: 1(MD010, no-hard-tabs)
141-141: Hard tabs
Column: 1(MD010, no-hard-tabs)
151-151: Hard tabs
Column: 1(MD010, no-hard-tabs)
153-153: Hard tabs
Column: 1(MD010, no-hard-tabs)
157-157: Hard tabs
Column: 1(MD010, no-hard-tabs)
158-158: Hard tabs
Column: 1(MD010, no-hard-tabs)
173-173: Hard tabs
Column: 1(MD010, no-hard-tabs)
175-175: Hard tabs
Column: 1(MD010, no-hard-tabs)
177-177: Hard tabs
Column: 1(MD010, no-hard-tabs)
181-181: Hard tabs
Column: 1(MD010, no-hard-tabs)
187-187: Hard tabs
Column: 1(MD010, no-hard-tabs)
192-192: Hard tabs
Column: 1(MD010, no-hard-tabs)
194-194: Hard tabs
Column: 1(MD010, no-hard-tabs)
195-195: Hard tabs
Column: 1(MD010, no-hard-tabs)
197-197: Hard tabs
Column: 1(MD010, no-hard-tabs)
198-198: Hard tabs
Column: 1(MD010, no-hard-tabs)
204-204: Hard tabs
Column: 1(MD010, no-hard-tabs)
205-205: Hard tabs
Column: 1(MD010, no-hard-tabs)
206-206: Hard tabs
Column: 1(MD010, no-hard-tabs)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
parsley/go.mod
is excluded by!**/*.mod
parsley/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (3)
parsley/README.md
(1 hunks)parsley/cmd/main.go
(1 hunks)parsley/internal/route_handlers/greeter.go
(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
parsley/README.md
58-58: Hard tabs
Column: 1
(MD010, no-hard-tabs)
60-60: Hard tabs
Column: 1
(MD010, no-hard-tabs)
61-61: Hard tabs
Column: 1
(MD010, no-hard-tabs)
63-63: Hard tabs
Column: 1
(MD010, no-hard-tabs)
68-68: Hard tabs
Column: 1
(MD010, no-hard-tabs)
70-70: Hard tabs
Column: 1
(MD010, no-hard-tabs)
71-71: Hard tabs
Column: 1
(MD010, no-hard-tabs)
72-72: Hard tabs
Column: 1
(MD010, no-hard-tabs)
73-73: Hard tabs
Column: 1
(MD010, no-hard-tabs)
90-90: Hard tabs
Column: 1
(MD010, no-hard-tabs)
91-91: Hard tabs
Column: 1
(MD010, no-hard-tabs)
92-92: Hard tabs
Column: 1
(MD010, no-hard-tabs)
98-98: Hard tabs
Column: 1
(MD010, no-hard-tabs)
99-99: Hard tabs
Column: 1
(MD010, no-hard-tabs)
100-100: Hard tabs
Column: 1
(MD010, no-hard-tabs)
101-101: Hard tabs
Column: 1
(MD010, no-hard-tabs)
103-103: Hard tabs
Column: 1
(MD010, no-hard-tabs)
104-104: Hard tabs
Column: 1
(MD010, no-hard-tabs)
106-106: Hard tabs
Column: 1
(MD010, no-hard-tabs)
110-110: Hard tabs
Column: 1
(MD010, no-hard-tabs)
128-128: Hard tabs
Column: 1
(MD010, no-hard-tabs)
134-134: Hard tabs
Column: 1
(MD010, no-hard-tabs)
135-135: Hard tabs
Column: 1
(MD010, no-hard-tabs)
136-136: Hard tabs
Column: 1
(MD010, no-hard-tabs)
137-137: Hard tabs
Column: 1
(MD010, no-hard-tabs)
141-141: Hard tabs
Column: 1
(MD010, no-hard-tabs)
151-151: Hard tabs
Column: 1
(MD010, no-hard-tabs)
153-153: Hard tabs
Column: 1
(MD010, no-hard-tabs)
157-157: Hard tabs
Column: 1
(MD010, no-hard-tabs)
158-158: Hard tabs
Column: 1
(MD010, no-hard-tabs)
173-173: Hard tabs
Column: 1
(MD010, no-hard-tabs)
175-175: Hard tabs
Column: 1
(MD010, no-hard-tabs)
177-177: Hard tabs
Column: 1
(MD010, no-hard-tabs)
181-181: Hard tabs
Column: 1
(MD010, no-hard-tabs)
187-187: Hard tabs
Column: 1
(MD010, no-hard-tabs)
192-192: Hard tabs
Column: 1
(MD010, no-hard-tabs)
194-194: Hard tabs
Column: 1
(MD010, no-hard-tabs)
195-195: Hard tabs
Column: 1
(MD010, no-hard-tabs)
197-197: Hard tabs
Column: 1
(MD010, no-hard-tabs)
198-198: Hard tabs
Column: 1
(MD010, no-hard-tabs)
204-204: Hard tabs
Column: 1
(MD010, no-hard-tabs)
205-205: Hard tabs
Column: 1
(MD010, no-hard-tabs)
206-206: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🔇 Additional comments (5)
parsley/cmd/main.go (1)
12-13
: LGTM: Nice readability improvementThe addition of a blank line at the beginning of the main function improves code readability by providing better visual separation between the function signature and the first statement.
parsley/internal/route_handlers/greeter.go (1)
27-28
:❓ Verification inconclusive
Be aware of behavior change in error handling
The error handling for the "polite" query parameter has been simplified but introduces a behavior change. Previously, if parsing failed, it would likely default to
true
. Now if parsing fails, the zero value (false
) will be used instead.This might affect how the API responds to invalid "polite" parameter values.
🏁 Script executed:
#!/bin/bash # Check if there are any tests that depend on this behavior rg -A 5 -B 5 "polite.*ParseBool" --glob "*.go" --glob "*.json" --glob "*.md" | grep -v "parsley/internal/route_handlers/greeter.go"Length of output: 633
Action Required: Confirm default behavior for invalid “polite” parameter values
We’ve simplified error handling in
parsley/internal/route_handlers/greeter.go
(lines 27–28):
politeFlag := ctx.Query("polite", defaultPoliteFlag)
polite, _ := strconv.ParseBool(politeFlag)
Now, any invalid Boolean string (e.g.
?polite=notabool
) silently falls back to Go’s zero value (false
). Previously, code would have defaulted todefaultPoliteFlag
(typically"true"
) on parse errors.This change may alter your API’s behavior for malformed
polite
parameters. Please verify that falling back tofalse
is intended. If not, consider:
- Restoring an explicit error check and assigning
polite = defaultPoliteValue
on parse failure- Adding unit tests to cover invalid
polite
values- Updating the example in README.md to match the intended behavior
parsley/README.md (3)
13-41
: Great documentation improvementsThe addition of the Prerequisites section and the reformatted Key Features and Overview sections significantly improve the documentation clarity. The inclusion of Go version requirements (1.23+) helps users understand compatibility constraints.
43-212
: Excellent step-by-step tutorialThe comprehensive step-by-step guide with detailed code examples makes the recipe much more accessible. The breakdown of each component (Fiber instance configuration, service registration, route handlers) with code snippets provides a clear learning path for users.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
58-58: Hard tabs
Column: 1(MD010, no-hard-tabs)
60-60: Hard tabs
Column: 1(MD010, no-hard-tabs)
61-61: Hard tabs
Column: 1(MD010, no-hard-tabs)
63-63: Hard tabs
Column: 1(MD010, no-hard-tabs)
68-68: Hard tabs
Column: 1(MD010, no-hard-tabs)
70-70: Hard tabs
Column: 1(MD010, no-hard-tabs)
71-71: Hard tabs
Column: 1(MD010, no-hard-tabs)
72-72: Hard tabs
Column: 1(MD010, no-hard-tabs)
73-73: Hard tabs
Column: 1(MD010, no-hard-tabs)
90-90: Hard tabs
Column: 1(MD010, no-hard-tabs)
91-91: Hard tabs
Column: 1(MD010, no-hard-tabs)
92-92: Hard tabs
Column: 1(MD010, no-hard-tabs)
98-98: Hard tabs
Column: 1(MD010, no-hard-tabs)
99-99: Hard tabs
Column: 1(MD010, no-hard-tabs)
100-100: Hard tabs
Column: 1(MD010, no-hard-tabs)
101-101: Hard tabs
Column: 1(MD010, no-hard-tabs)
103-103: Hard tabs
Column: 1(MD010, no-hard-tabs)
104-104: Hard tabs
Column: 1(MD010, no-hard-tabs)
106-106: Hard tabs
Column: 1(MD010, no-hard-tabs)
110-110: Hard tabs
Column: 1(MD010, no-hard-tabs)
128-128: Hard tabs
Column: 1(MD010, no-hard-tabs)
134-134: Hard tabs
Column: 1(MD010, no-hard-tabs)
135-135: Hard tabs
Column: 1(MD010, no-hard-tabs)
136-136: Hard tabs
Column: 1(MD010, no-hard-tabs)
137-137: Hard tabs
Column: 1(MD010, no-hard-tabs)
141-141: Hard tabs
Column: 1(MD010, no-hard-tabs)
151-151: Hard tabs
Column: 1(MD010, no-hard-tabs)
153-153: Hard tabs
Column: 1(MD010, no-hard-tabs)
157-157: Hard tabs
Column: 1(MD010, no-hard-tabs)
158-158: Hard tabs
Column: 1(MD010, no-hard-tabs)
173-173: Hard tabs
Column: 1(MD010, no-hard-tabs)
175-175: Hard tabs
Column: 1(MD010, no-hard-tabs)
177-177: Hard tabs
Column: 1(MD010, no-hard-tabs)
181-181: Hard tabs
Column: 1(MD010, no-hard-tabs)
187-187: Hard tabs
Column: 1(MD010, no-hard-tabs)
192-192: Hard tabs
Column: 1(MD010, no-hard-tabs)
194-194: Hard tabs
Column: 1(MD010, no-hard-tabs)
195-195: Hard tabs
Column: 1(MD010, no-hard-tabs)
197-197: Hard tabs
Column: 1(MD010, no-hard-tabs)
198-198: Hard tabs
Column: 1(MD010, no-hard-tabs)
204-204: Hard tabs
Column: 1(MD010, no-hard-tabs)
205-205: Hard tabs
Column: 1(MD010, no-hard-tabs)
206-206: Hard tabs
Column: 1(MD010, no-hard-tabs)
213-226
: Clear application execution instructionsThe run instructions are now much clearer with specific commands to start the application and test the endpoint. This significantly improves the user experience when following the tutorial.
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: 1
🧹 Nitpick comments (5)
parsley/README.md (5)
28-33
: Fix verb agreement in Key features
Line 31 reads “Constructor-based dependency injection wire services together.” It should be “wires services together” or “wiring services together.”- * **Automatic dependency injection:** Constructor-based dependency injection wire services together. + * **Automatic dependency injection:** Constructor-based dependency injection wires services together.🧰 Tools
🪛 LanguageTool
[uncategorized] ~31-~31: This verb does not appear to agree with the subject. Consider using a different form.
Context: ... Constructor-based dependency injection wire services together. * **Simplified route...(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
54-74
: Rename shadowedcontext
variable inmain
Usingcontext
as a local variable shadows the importedcontext
package. It’s idiomatic to name itctx
.- func main() { - context := context.Background() + func main() { + ctx := context.Background() // Runs a Fiber instance as a Parsley-enabled app - bootstrap.RunParsleyApplication(context, internal.NewApp, + bootstrap.RunParsleyApplication(ctx, internal.NewApp, modules.ConfigureFiber, modules.ConfigureGreeter) }
148-156
: Route-handler import order follows Go conventions
Consider grouping standard, external, then local imports (strconv
,github.com/fiber/...
, thenparsley-app/internal/services
).import ( - "strconv" - "parsley-app/internal/services" - "github.com/gofiber/fiber/v2" + "strconv" + + "github.com/gofiber/fiber/v2" + + "parsley-app/internal/services" )
168-176
: HandleSayHelloRequest: consider explicit error handling
Currently, parse errors are ignored instrconv.ParseBool
. For robust examples, you might return400 Bad Request
on invalid input.polite, err := strconv.ParseBool(politeFlag) if err != nil { return ctx.Status(fiber.StatusBadRequest).SendString("invalid polite flag") }
197-200
: Clarify default listening port incurl
example
The port5502
appears without context—consider noting that it’s the default in this example or making it configurable.For this recipe the default listening port is 5502:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
parsley/README.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
parsley/README.md
[uncategorized] ~31-~31: This verb does not appear to agree with the subject. Consider using a different form.
Context: ... Constructor-based dependency injection wire services together. * **Simplified route...
(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
🔇 Additional comments (14)
parsley/README.md (14)
14-17
: Prerequisites section is clear and helpful
Good addition; this makes it explicit which Go version is needed to run the example.
21-26
: Overview bullets are concise and accurate
The three-step overview (bootstrap, register, resolve) cleanly communicates the example’s flow.
43-50
: Step-by-step guide is clear
Good instructions for cloning and navigating to the example directory.
76-79
: RunParsleyApplication description reads well
This paragraph effectively explains how the bootstrap function orchestrates the app.
81-84
: Configure and register Fiber header & intro are on point
The heading and lead-in clearly introduce the Fiber-registration section.
86-93
: Imports inmodules
snippet look correct
The example shows the necessary imports forConfigureFiber
.
95-104
:ConfigureFiber
implementation is accurate
The singleton registration of Fiber and the route-handlers module invocation match the code.
107-110
:newFiber
factory is clear
This helper function is straightforward and well documented.
115-118
: Service definition section is well explained
The description sets up the subsequent code snippet nicely.
119-140
:Greeter
service snippet is correct
The interface and implementation align with the tutorial narrative.
158-163
:greeterRouteHandler
struct and const are clear
The code correctly shows dependency injection for the greeter service.
164-167
: Route registration is straightforward
Good demonstration of how to wire a handler into Fiber’s routing.
179-185
: Factory forgreeterRouteHandler
is well presented
The constructor function matches the DI pattern introduced earlier.
189-194
: Run application snippet is accurate
Clear instruction to start the app viago run
.
32bb289
to
fb02451
Compare
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 (3)
parsley/README.md (3)
13-17
: Consider expanding the prerequisites
The new Prerequisites section is a great addition. To help users run this example in isolation, you might also mention initializing the Go module (e.g.,go mod init github.com/gofiber/recipes/parsley-app
) and ensuring Go is on their PATH (or link to Go installation docs).
46-49
: Optimize clone instructions
To reduce clone time and bandwidth, consider a shallow clone flag. For example:git clone --depth 1 https://github.com/gofiber/recipes.git parsleyThis speeds up the workflow for users exploring just the
parsley
example.
53-74
:❓ Verification inconclusive
Verify module import paths and refine inline comment
The snippet correctly shows fully qualified imports, but please double-check thatparsley-app/go.mod
declares:module github.com/gofiber/recipes/parsley-app
to match these paths. Also, for consistency with Go’s commenting style, add a trailing period to the inline comment on the
RunParsleyApplication
call.Example diff:
--- a/parsley/README.md +++ b/parsley/README.md @@ -69,7 +69,7 - // Runs a Fiber instance as a Parsley-enabled app + // Runs a Fiber instance as a Parsley-enabled app.You can verify the module path with:
🏁 Script executed:
#!/bin/bash rg -n '^module github.com/gofiber/recipes/parsley-app$' parsley-app/go.modLength of output: 135
🏁 Script executed:
#!/bin/bash # Locate all go.mod files and print their module declarations find . -type f -name go.mod -exec echo "==> {} <==" \; -exec sed -n '1,5p' {} \;Length of output: 84
Verify module path & inline comment
I couldn’t locate ago.mod
in theparsley-app/
directory—please confirm:
- A file at
parsley-app/go.mod
exists and its first line reads:module github.com/gofiber/recipes/parsley-app
- The inline comment on the
RunParsleyApplication
call ends with a period for Go-style consistency:--- a/parsley/README.md +++ b/parsley/README.md @@ -69,7 +69,7 - // Runs a Fiber instance as a Parsley-enabled app + // Runs a Fiber instance as a Parsley-enabled app.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
parsley/README.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
parsley/README.md
[typographical] ~220-~220: Use a comma after an introductory phrase.
Context: ...ser, or from the terminal using curl
. For this recipe the default listening port is `5...
(COMMA_INTRODUCTORY_WORDS_PHRASES)
[typographical] ~220-~220: It appears that a comma is missing.
Context: ...rom the terminal using curl
. For this recipe the default listening port is 5502
: ...
(DURING_THAT_TIME_COMMA)
🔇 Additional comments (4)
parsley/README.md (4)
21-25
: Clear and concise Overview
The Overview bullets succinctly outline bootstrapping, registration, and resolution steps. This high-level summary is spot on.
28-32
: Well-structured Key features
The Key features section is informative and consistently formatted. Nice work!
35-39
: Consistent list formatting in “How it works”
Each bullet now correctly has a leading*
. The list is uniform and easy to follow.
42-45
: Step-by-step heading and intro
Introducing the “The recipe – step by step” section with a brief guide sets clear expectations for readers. Looks good.
fb02451
to
3f1e861
Compare
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)
parsley/README.md (1)
220-220
: Typographical fix: comma after introductory phrase
Add a comma after “For this recipe” to improve readability.- …using `curl`. For this recipe the default listening port is `5502`: + …using `curl`. For this recipe, the default listening port is `5502`:🧰 Tools
🪛 LanguageTool
[typographical] ~220-~220: Use a comma after an introductory phrase.
Context: ...ser, or from the terminal usingcurl
. For this recipe the default listening port is `5...(COMMA_INTRODUCTORY_WORDS_PHRASES)
[typographical] ~220-~220: It appears that a comma is missing.
Context: ...rom the terminal usingcurl
. For this recipe the default listening port is5502
: ...(DURING_THAT_TIME_COMMA)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
parsley/go.mod
is excluded by!**/*.mod
parsley/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (6)
parsley/README.md
(1 hunks)parsley/cmd/main.go
(1 hunks)parsley/internal/application.go
(1 hunks)parsley/internal/modules/greeter_module.go
(1 hunks)parsley/internal/modules/route_handlers_module.go
(1 hunks)parsley/internal/route_handlers/greeter.go
(2 hunks)
✅ Files skipped from review due to trivial changes (3)
- parsley/internal/modules/route_handlers_module.go
- parsley/internal/application.go
- parsley/internal/route_handlers/greeter.go
🚧 Files skipped from review as they are similar to previous changes (2)
- parsley/internal/modules/greeter_module.go
- parsley/cmd/main.go
🧰 Additional context used
🪛 LanguageTool
parsley/README.md
[typographical] ~220-~220: Use a comma after an introductory phrase.
Context: ...ser, or from the terminal using curl
. For this recipe the default listening port is `5...
(COMMA_INTRODUCTORY_WORDS_PHRASES)
[typographical] ~220-~220: It appears that a comma is missing.
Context: ...rom the terminal using curl
. For this recipe the default listening port is 5502
: ...
(DURING_THAT_TIME_COMMA)
🔇 Additional comments (6)
parsley/README.md (6)
13-17
: Well-structured “Prerequisites” section
The new Prerequisites section clearly states the minimum Go version required. This addition improves discoverability of setup requirements for readers.
21-25
: Clear and concise “Overview” section
The steps “Bootstrap the application”, “Register dependencies”, and “Resolve dependencies” are well articulated. This helps readers quickly grasp the high-level workflow.
28-32
: Informative “Key features” list
The bullet points succinctly highlight modularity, DI, and route management benefits. This enhances the readability of feature highlights.
37-40
: Consistent “How it works” explanation
The three bullets uniformly describe the roles ofmain
, modules, and route handlers. The formatting is now consistent.
42-49
: Comprehensive “The recipe – step by step” guide
The added instructional text and shell snippet (git clone…
,cd recipes/parsley
) provide a smooth onboarding path. The use of a fencedsh
block is appropriate for clarity.
53-62
:❓ Verification inconclusive
Verify updated import paths in
cmd/main.go
snippet
The fully qualified module paths undergithub.com/gofiber/recipes/parsley-app
appear correct, but please ensure they match themodule
declaration in yourgo.mod
.Run this script from the repo root to confirm no missing or stale imports:
🏁 Script executed:
#!/bin/bash # Search for import statements in the example rg --type-go 'github.com/gofiber/recipes/parsley-app/internal' -A2Length of output: 504
To properly verify both your
module
declaration and the updated import paths, let’s re-run with a corrected check:This will confirm that:
- Your
go.mod
’smodule
line matchesgithub.com/gofiber/recipes/parsley-app
.- All imports of
parsley-app/internal
in your.go
files are up-to-date.
🏁 Script executed:
#!/bin/bash # Check the module path in go.mod echo "Module declaration:" grep '^module ' go.mod # Search all Go files for the parsley-app/internal import echo -e "\nFound imports:" rg 'github.com/gofiber/recipes/parsley-app/internal' -A2 --glob '*.go'Length of output: 1428
Let’s locate the
go.mod
file(s) and verify theirmodule
declarations:
🏁 Script executed:
#!/usr/bin/env bash echo "Searching for go.mod files..." find . -type f -name go.mod echo -e "\nModule declarations found:" find . -type f -name go.mod -exec grep '^module ' {} \;Length of output: 228
Confirm presence of
go.mod
and module declaration
I wasn’t able to locate ago.mod
file in the repo—please ensure:
- A
go.mod
exists at the repository (or relevant submodule) root.- Its
module
line is set togithub.com/gofiber/recipes/parsley-app
.- All imports (e.g.
github.com/gofiber/recipes/parsley-app/internal/...
) match that module path.
eea8398
to
ff8ffec
Compare
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)
parsley/README.md (1)
56-64
: Reorder import groups for idiomatic Go style
Consider grouping imports in this order: standard library, external packages, then internal modules. For example:import ( "context" "github.com/matzefriedrich/parsley/pkg/bootstrap" "github.com/gofiber/recipes/parsley-app/internal" "github.com/gofiber/recipes/parsley-app/internal/modules" )This aligns with common Go conventions and improves readability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
parsley/go.mod
is excluded by!**/*.mod
parsley/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (6)
parsley/README.md
(1 hunks)parsley/cmd/main.go
(1 hunks)parsley/internal/application.go
(1 hunks)parsley/internal/modules/greeter_module.go
(1 hunks)parsley/internal/modules/route_handlers_module.go
(1 hunks)parsley/internal/route_handlers/greeter.go
(2 hunks)
✅ Files skipped from review due to trivial changes (2)
- parsley/internal/application.go
- parsley/internal/modules/route_handlers_module.go
🚧 Files skipped from review as they are similar to previous changes (3)
- parsley/internal/route_handlers/greeter.go
- parsley/cmd/main.go
- parsley/internal/modules/greeter_module.go
🔇 Additional comments (6)
parsley/README.md (6)
13-16
: Add Prerequisites section – Good addition
Clearly states the required Go version for this example, helping users prepare their environment.
21-26
: Overview bullets are clear and concise
The three-step breakdown (bootstrap, register, resolve) provides a straightforward introduction to using Parsley with GoFiber.
29-33
: Key features list is well-structured
Effectively highlights the modular configuration, automatic DI, and simplified route management benefits.
35-39
: How it works section reads smoothly
Succinctly explains bootstrapping, module configuration, and handler injection using theGreeter
service.
42-49
: Step-by-step guide is thorough
The “The recipe – step by step” walkthrough, including clone commands, makes the example very approachable.
65-73
: Main function example aligns with the tutorial
TheRunParsleyApplication
invocation and its parameters (internal.NewApp
,ConfigureFiber
,ConfigureGreeter
) correctly illustrate the bootstrapping process described above.
ff8ffec
to
2a81db7
Compare
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: 1
🧹 Nitpick comments (12)
parsley/README.md (12)
14-17
: Clarify Parsley installation in Prerequisites
The Prerequisites section specifies “Go 1.23+”, but it doesn’t mention how to obtain or install the Parsley framework itself. Please add a note or link about fetching the Parsley module (e.g.,go get github.com/matzefriedrich/parsley@latest
) or installing any CLI tooling if required.
21-25
: Enhance Overview with direct Parsley documentation link
The Overview refers to “Parsley” but doesn’t link the term to the official docs or repo. Consider hyperlinking to the Parsley GitHub or official documentation to help readers dive deeper:* **Bootstrap the application:** Set up and configure the Fiber app using [Parsley’s DI container](https://github.com/matzefriedrich/parsley).
28-32
: Ensure consistent bullet punctuation in Key features
Some bullet items end with periods and others don’t. For consistency and readability, either remove all trailing punctuation or add a period at the end of each item.
35-39
: Polish “How it works” introductory bullets
The section starts with “## How it works” but the first two bullets are unmodified from before. Consider adding a brief sentence after the header to introduce the list, for example:Below is an overview of how Parsley wires your application components together.
42-45
: Add context before “The recipe – step by step”
The heading jumps straight into the guide. It may help to introduce the section with a one-line summary, e.g.:In this step-by-step recipe, we’ll build and run a Parsley-enabled Fiber app from scratch.
46-49
: Annotate shell snippet with prerequisites
Before cloning, it might be helpful to remind users to install Git or enable modules, e.g.:# Ensure you have Git installed and Go modules enabled (GO111MODULE=on) git clone https://github.com/gofiber/recipes.git cd recipes/parsley
51-52
: Clarify file location forcmd/main.go
The text says “The main entry point of the application is in thecmd/main.go
.” Consider specifying the full path from the repo root—recipes/parsley/cmd/main.go
—so users don’t get lost if they’re not in the example folder.
77-79
: Smooth transition from code to explanation
The paragraph “In this file, theRunParsleyApplication
function bootstraps the application…” follows immediately after the code. Consider adding a brief “Explanation” subheading or a blank line for visual separation.
81-83
: Add subheading consistency for module configuration
You’ve introduced “### Configure and register the Fiber instance”. To maintain consistency, ensure all major steps (“RunParsleyApplication”, “ConfigureFiber”, etc.) follow the same ###-level format and appear in the TOC if one is present.
116-119
: Add Go doc comments for Greeter service
The Greeter interface and implementation are clear, but adding Go-style doc comments (e.g., abovetype Greeter interface
) will improve readability for users scanning the code.
163-206
: Improve clarity around route handler registration
The section on route handlers is comprehensive, but readers may benefit from a brief diagram or list that outlines the interfaces (RouteHandler
), the factory (NewGreeterRouteHandler
), and the registration flow before diving into code.
211-224
: Mention default listening port earlier
The curl example uses port5502
, but the README doesn’t state where this default port is configured. Suggest adding a note on how to override the port (e.g., via environment variable or Fiber config) or where in the code the default is set.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
parsley/go.mod
is excluded by!**/*.mod
parsley/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (6)
parsley/README.md
(1 hunks)parsley/cmd/main.go
(1 hunks)parsley/internal/application.go
(1 hunks)parsley/internal/modules/greeter_module.go
(1 hunks)parsley/internal/modules/route_handlers_module.go
(1 hunks)parsley/internal/route_handlers/greeter.go
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- parsley/internal/application.go
🚧 Files skipped from review as they are similar to previous changes (4)
- parsley/internal/modules/route_handlers_module.go
- parsley/internal/route_handlers/greeter.go
- parsley/internal/modules/greeter_module.go
- parsley/cmd/main.go
🔇 Additional comments (3)
parsley/README.md (3)
53-74
: Verify module path matches go.mod in code snippet
The imports usegithub.com/gofiber/recipes/parsley-app/internal
, but the directory here is namedparsley
. Please confirm that thego.mod
module directive ismodule github.com/gofiber/recipes/parsley-app
(notparsley
), or adjust the paths in the README to match the actual module path.
85-111
: ConfirmRegisterRouteHandlers
is imported and documented
The code callsregistry.RegisterModule(RegisterRouteHandlers)
, but the import forRegisterRouteHandlers
isn’t shown here. Verify that the sample includes an import for the module package whereRegisterRouteHandlers
is defined, or add a comment indicating where to find it.
144-158
: Document the Greeter registration factory
The snippet usesservices.NewGreeterFactory
but the service constructor in the earlier section is namedNewGreeter()
. Please confirm whether the factory function isNewGreeter
orNewGreeterFactory
, and update the example for consistency.
```go | ||
package services | ||
|
||
import "fmt" | ||
|
||
type Greeter interface { | ||
SayHello(name string, polite bool) string | ||
} | ||
|
||
type greeter struct{} | ||
|
||
func (g *greeter) SayHello(name string, polite bool) string { | ||
if polite { | ||
return fmt.Sprintf("Good day, %s!\n", name) | ||
} | ||
return fmt.Sprintf("Hi, %s\n", name) | ||
} | ||
|
||
func NewGreeter() Greeter { | ||
return &greeter{} | ||
} |
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.
🛠️ Refactor suggestion
Handle boolean parsing errors in the route handler
In production code, swallowing the error from strconv.ParseBool
can lead to unexpected behavior. Consider handling the error explicitly or providing a default response if parsing fails. For example:
polite, err := strconv.ParseBool(politeFlag)
if err != nil {
return ctx.Status(fiber.StatusBadRequest).SendString("invalid 'polite' flag")
}
🤖 Prompt for AI Agents
In parsley/README.md around lines 121 to 141, the code currently ignores errors
from strconv.ParseBool when parsing the 'polite' flag, which can cause
unexpected behavior. Modify the route handler to explicitly check the error
returned by strconv.ParseBool, and if an error occurs, respond with a bad
request status and an appropriate error message indicating the 'polite' flag is
invalid. This ensures robust error handling and clearer client feedback.
…andleSayHelloRequest)
2a81db7
to
e44b348
Compare
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: 1
🧹 Nitpick comments (1)
parsley/README.md (1)
13-17
: Clarify Go version requirement
Consider specifying the version constraint more explicitly (e.g., “Go 1.23 or higher”) or linking to the official Go installation guide. This helps onboard users who may not have the required version installed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
parsley/go.mod
is excluded by!**/*.mod
parsley/go.sum
is excluded by!**/*.sum
,!**/*.sum
📒 Files selected for processing (6)
parsley/README.md
(1 hunks)parsley/cmd/main.go
(1 hunks)parsley/internal/application.go
(1 hunks)parsley/internal/modules/greeter_module.go
(1 hunks)parsley/internal/modules/route_handlers_module.go
(1 hunks)parsley/internal/route_handlers/greeter.go
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- parsley/internal/modules/route_handlers_module.go
🚧 Files skipped from review as they are similar to previous changes (4)
- parsley/internal/application.go
- parsley/internal/route_handlers/greeter.go
- parsley/internal/modules/greeter_module.go
- parsley/cmd/main.go
🔇 Additional comments (4)
parsley/README.md (4)
21-25
: Well-structured overview section
The new bullet list clearly outlines the main steps of using Parsley (bootstrapping, registering, resolving). It’s concise and reader-friendly.
28-32
: Key features formatting
Great job on highlighting modular configuration, automatic DI, and simplified route management. The formatting is consistent and easy to scan.
65-68
: Avoid shadowing thecontext
package
Renaming the application context variable toctx
is a good practice to prevent collisions with the importedcontext
package.
70-73
: Correct DI bootstrapping call
The call tobootstrap.RunParsleyApplication(ctx, internal.NewApp, modules.ConfigureFiber, modules.ConfigureGreeter)
accurately reflects the intended registration order and usage.
## The recipe - step by step | ||
|
||
This guide demonstrates integrating the Parsley dependency injection framework with the GoFiber web framework. You can either clone the GoFiber recipes repository and navigate to the **parsley** example, or replicate each module while following the article: | ||
|
||
```sh | ||
git clone https://github.com/gofiber/recipes.git | ||
cd recipes/parsley | ||
``` |
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.
Mismatch between example directory and import paths
The instructions say to cd recipes/parsley
, but the code sample imports from github.com/gofiber/recipes/parsley-app/internal
. Please align the directory name and module path—either update the cd
command to parsley-app
or adjust the import paths (and your module declaration in go.mod) to match the actual folder structure.
Also applies to: 59-60
🤖 Prompt for AI Agents
In parsley/README.md around lines 42 to 49, the directory name in the cd command
does not match the import paths used in the code, causing confusion. Update the
cd command from "cd recipes/parsley" to "cd recipes/parsley-app" to align with
the import paths referencing "parsley-app/internal". Alternatively, adjust the
import paths and the module declaration in go.mod to match the existing
directory name if you prefer to keep the current folder structure.
This PR contains an update for the
parsley
recipe.Changes
matzefriedrich/parsley
packageSummary by CodeRabbit