-
Notifications
You must be signed in to change notification settings - Fork 0
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
コメント周りのAPIを実装 #12
コメント周りのAPIを実装 #12
Conversation
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.
ざっくりコメント付けました〜
model/comments.go
Outdated
} | ||
|
||
func CreateComment(p *CreateCommentPayload) (*Comment, error) { | ||
if p.ItemID == 0 { |
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.
[q] これ、ItemID=0
のものは弾くということであってる?
[q] Invalid な ItemID
が来たときは弾かない?弾いたほうが良さそうに見えるけど
{ | ||
name: "異常系: ItemIDが存在しない", | ||
payload: &CreateCommentPayload{ | ||
UserID: "user1", |
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.
[imo] 0 を弾くのって話にも関連するけど、この場合 0 値として ItemId=0
がセットされているので、これを弾くのはちょっと気になるかも
router/comments.go
Outdated
return invalidRequest(c, err) | ||
} | ||
|
||
me := getAuthorizedUser(c) |
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.
[q] これって必ず失敗しない関数なの?(この 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.
内部で呼んでるのは echo.Context.Get
です
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.
:naruhodo: ちょっとコード読んだんだけど、AuthMiddleware
を通さない状態でこの関数を呼び出すと panic するので気を付けて!外部からは一切のエンドポイントを叩けなくても ok ならこの実装でも良いっちゃよいです
(それはそれとして getAuthorizedUser で panic 起きてもアプリケーションが落ちないようにしたほうがいいかも)
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.
:naruhodo: ちょっとコード読んだんだけど、AuthMiddleware を通さない状態でこの関数を呼び出すと panic するので気を付けて!外部からは一切のエンドポイントを叩けなくても ok という方針ならこの実装でも良いっちゃよいです
(それはそれとして getAuthorizedUser で panic 起きてもアプリケーションが落ちないようにしたほうがいいかも)
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.
panic するんですね :hae_zubora:
No description provided.