[GUN-12] Create GET /teams/:teamname/members route#23
Conversation
Co-authored-by: Lara Carvalho <laracarvalho@users.noreply.github.com>
Co-authored-by: Lara Carvalho <laracarvalho@users.noreply.github.com>
MiguelMachado-dev
left a comment
There was a problem hiding this comment.
Everything looks great, but, can we add a test to this route to make sure it returns everything perfect?
| teamName := ctx.Param("teamname") | ||
|
|
||
| if teamName == "" { | ||
| sendError(ctx, 404, "Team name is required") |
There was a problem hiding this comment.
Maybe we can use the http.StatusNotFound instead of the hardcoded http code for easy documentation and reading, what you think?
| err := db.Joins("JOIN teams ON teams.team_id = member.team_id").Where("teams.name = ?", teamName).Find(&schemas.Member{}) | ||
|
|
||
| if err != nil { | ||
| sendError(ctx, 404, "Team not found") |
There was a problem hiding this comment.
| } | ||
|
|
||
| type TeamNameRequest struct { | ||
| name string |
There was a problem hiding this comment.
Attribute name should be in lowercase?
| // @Produce json | ||
| // @Success 200 {object} ListTeamMembersResponse | ||
| // @Router /team/{teamname}/members [get] | ||
| func ListTeamMembersHandler(ctx *gin.Context) { |
There was a problem hiding this comment.
The names ListTeam and getTeam, they have the same meaning, what do you think about choosing one to have a consistent nomenclature? Make sense?
|
|
||
| var db *gorm.DB | ||
|
|
||
| func InitiliazeHandler() { |
There was a problem hiding this comment.
Did you mean Initialize?
| // initializeRoutes sets up the routes for the application | ||
| func initializeRoutes(r *gin.Engine) { | ||
| // Initialize handler | ||
| handler.InitiliazeHandler() |
rodrigofmeneses
left a comment
There was a problem hiding this comment.
Great work. Need just few improvements.
Description:
This pull request aims to implement the route /teams/:teamname/members to return the list of Forjadev members from each team.
Issue: #12
Changes Made: