-
Notifications
You must be signed in to change notification settings - Fork 26
Implement handlers #49
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
Conversation
server/handler/assignments.go
Outdated
return nil, fmt.Errorf("wrong format in experiment ID sent; received %s", requestedExperimentID) | ||
} | ||
|
||
// TODO: fetch from user in session |
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.
why don't use jwt.GetUserID
? Middleware is already there.
assignments, err := repository.GetAssignmentsFor(userID, experimentID) | ||
if err == repository.ErrNoAssignmentsInitialized { | ||
if assignments, err = repository.CreateAssignmentsFor(userID, experimentID); err != nil { | ||
return nil, fmt.Errorf("no available assignments") |
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.
the original error should be logged (ok to do in separate PR)
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.
I'll do so by #50
server/handler/assignments.go
Outdated
requestedAssignmentID := chi.URLParam(r, "assignmentId") | ||
assignmentID, err := strconv.Atoi(requestedAssignmentID) | ||
if err != nil { | ||
return nil, fmt.Errorf("wrong format in assignment ID sent; received %s", requestedAssignmentID) |
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.
it's not 500 but 404 or 400. Ok to do in separate PR.
also CI is failing with error
|
@smacker your comments were addressed 💃 |
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.
LGTM!
From the PR feedback: - Expose right HTTP status codes as spotted by @smacker
1158d7f
to
83592bf
Compare
partially solves #3
supersedes #16
edd1807 Implement
/experiment
handlers