Add solution for Challenge 5 by Raycas96#1565
Add solution for Challenge 5 by Raycas96#1565github-actions[bot] merged 2 commits intoRezaSi:mainfrom
Conversation
WalkthroughA Go HTTP server implementation has been added with authentication middleware and two endpoint handlers. The Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant Server as HTTP Server
participant AuthMW as AuthMiddleware
participant SecureHandler as secureHandler
rect rgba(0, 150, 0, 0.5)
Note over Client,SecureHandler: Request with Valid Token
Client->>Server: GET /secure<br/>X-Auth-Token: secret
Server->>AuthMW: Check authentication
AuthMW->>AuthMW: Validate token matches "secret"
AuthMW->>SecureHandler: Token valid, forward request
SecureHandler->>Client: 200 OK<br/>"You are authorized!"
end
rect rgba(150, 0, 0, 0.5)
Note over Client,SecureHandler: Request without Token
Client->>Server: GET /secure<br/>(no X-Auth-Token header)
Server->>AuthMW: Check authentication
AuthMW->>AuthMW: Token header missing
AuthMW->>Client: 401 Unauthorized
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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
🧹 Nitpick comments (1)
challenge-5/submissions/Raycas96/solution-template.go (1)
18-18: UsevalidTokenin the auth check and simplify the condition.At Line [18],
authHeader == "" || authHeader != "secret"is redundant and hardcodes the token literal again. Prefer a single comparison againstvalidToken.Proposed cleanup
- if authHeader == "" || authHeader != "secret" { + if authHeader != validToken { http.Error(w, "", http.StatusUnauthorized) return }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d033ea28-ecca-4f0a-94ec-3830bd562571
📒 Files selected for processing (1)
challenge-5/submissions/Raycas96/solution-template.go
| fmt.Fprint(w, "Hello!") | ||
| } | ||
|
|
||
| // secureHandler returns "You are authorized!" on GET /secure |
There was a problem hiding this comment.
Update the handler comment to avoid implying GET-only behavior.
Line [32] says “on GET /secure”, but this handler is correctly method-agnostic. Keeping the comment as-is can mislead future edits into adding method restrictions that would break expected behavior.
Based on learnings: In challenge-5/submissions/*/solution-template.go, ensure the secureHandler is method-agnostic (do not restrict it to GET), and tests include POST /secure with valid token expecting 200 OK.
|
🎉 Auto-merged! This PR was automatically merged after 2 days with all checks passing. Thank you for your contribution, @Raycas96! |
Challenge 5 Solution
Submitted by: @Raycas96
Challenge: Challenge 5
Description
This PR contains my solution for Challenge 5.
Changes
challenge-5/submissions/Raycas96/solution-template.goTesting
Thank you for reviewing my submission! 🚀