Skip to content
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 のアップデート #66

Merged
merged 13 commits into from
Jun 27, 2024

Conversation

TakanoHori
Copy link
Contributor

@TakanoHori TakanoHori commented Jun 26, 2024

概要

  • チャンネルの取得 API を /servers/:serverId/channels で取得するように更新しました。
  • 実装されたのが、repo の構成が確定する前だったので、usecase / interface を追加しました。
  • DB にアクセスするときに、name しか取得していなかったので、他のカラムも取得するようにしました。
  • deleted_at IS NULL を入れて、削除されていないチャンネルのみを取得するようにしました。

Issue

closes #60

動作確認

  1. (必要なら)サインアップ

    curl -X POST -H "Content-Type: application/json" -d '{"name":<<ユーザー名>>,"password":<<パスワード>>}' http://localhost:9090/user/new
    
  2. サインインして TOKEN をコピーしておいてください。

    • このコマンドでは、cookie.txt で受け取ることにしてます
    curl -X POST -H "Content-Type: application/json" -d '{"name":<<ユーザー名>>,"password":<<パスワード>>}' http://localhost:9090/user/signin -c ./cookie.txt
    
  3. TOKEN を以下のコマンドに埋め込んで、実行してください。

    curl -X GET 'localhost:9000/servers/1/channels' -b "training-jwt=<<トークン>>"
    

レスポンス

  • created_at / updated_at がテーブルの日付になっているか確認をお願いします。
    {"channels":[{"id":1,"server_id":1,"name":"channel1","created_at":"2024-06-27T11:30:19+09:00","updated_at":"2024-06-27T11:30:19+09:00"},{"id":2,"server_id":1,"name":"channel2","created_at":"2024-06-27T11:30:19+09:00","updated_at":"2024-06-27T11:30:19+09:00"}]}
    

@TakanoHori TakanoHori changed the title Fix/get channel update チャンネルの取得 API のアップデート Jun 27, 2024
@TakanoHori TakanoHori self-assigned this Jun 27, 2024
@TakanoHori TakanoHori marked this pull request as ready for review June 27, 2024 02:24
@TakanoHori
Copy link
Contributor Author

jwt まわりの更新を入れてからレビューしてもらう。

@TakanoHori TakanoHori changed the title チャンネルの取得 API のアップデート チャンネル API のアップデート Jun 27, 2024
> panic: ':serverId' in new path '/servers/:serverId/channels/:channelId/posts' conflicts with existing wildcard ':id' in existing prefix '/servers/:id'
を避けるため
authorized.GET("/servers/:id/channels", controllers.GetChannels)
authorized.GET("/servers/:serverId/channels", controllers.GetChannels)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic: ':serverId' in new path '/servers/:serverId/channels/:channelId/posts' conflicts with existing wildcard ':id' in existing prefix '/servers/:id'

投稿などで 2つ id を管理する場合、このエラーでこけることがあったため、分けられるようにする。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TakanoHori TakanoHori changed the title チャンネル API のアップデート チャンネルの取得 API のアップデート Jun 27, 2024
Copy link
Contributor

@syougo1209 syougo1209 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@TakanoHori TakanoHori merged commit 6e254d5 into main Jun 27, 2024
2 checks passed
@TakanoHori TakanoHori deleted the fix/get-channel-update branch June 27, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

チャンネルの一覧を取得する API のアップデート
2 participants