-
Notifications
You must be signed in to change notification settings - Fork 0
feat(delete_channel):チャンネルの削除を実装 #37
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ import ( | |||||||
|
||||||||
type ChannelHandler interface { | ||||||||
HandleInsert(ctx *gin.Context) | ||||||||
HandleDelete(ctx *gin.Context) | ||||||||
HandleGetByID(ctx *gin.Context) | ||||||||
HandleAddUserToChannel(ctx *gin.Context) | ||||||||
HandleGetMessagesInChannel(ctx *gin.Context) | ||||||||
|
@@ -62,6 +63,23 @@ func (ch *channelHandler) HandleInsert(ctx *gin.Context) { | |||||||
}) | ||||||||
} | ||||||||
|
||||||||
func (ch *channelHandler) HandleDelete(ctx *gin.Context) { | ||||||||
slog.DebugContext(ctx, "HandleDelete") | ||||||||
|
||||||||
var uri types.ChannelURI | ||||||||
if err := ctx.BindUri(&uri); err != nil { | ||||||||
slog.ErrorContext(ctx, err.Error()) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When URI binding fails, the handler logs the error but does not set a response status, leaving the client hanging. Consider returning a 400 Bad Request (e.g., ctx.AbortWithStatusJSON(http.StatusBadRequest, ...)).
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||
return | ||||||||
} | ||||||||
err := ch.channelUseCase.Delete(uri.ID) | ||||||||
if err != nil { | ||||||||
slog.ErrorContext(ctx, err.Error()) | ||||||||
ctx.Status(http.StatusInternalServerError) | ||||||||
return | ||||||||
} | ||||||||
ctx.Status(http.StatusNoContent) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ボディーは空でHTTP204だけを返す |
||||||||
} | ||||||||
|
||||||||
func (ch *channelHandler) HandleGetByID(ctx *gin.Context) { | ||||||||
slog.DebugContext(ctx, "HandleGetByID") | ||||||||
|
||||||||
|
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.
This Delete call does not check RowsAffected, so deleting a non-existent channel returns no error. Consider checking result.RowsAffected and returning a not-found error if zero rows were deleted.
Copilot uses AI. Check for mistakes.