Kadai4 hioki-daichi - #65
Open
hioki-daichi wants to merge 12 commits into
Open
hioki-daichi wants to merge 12 commits into
hioki-daichi wants to merge 12 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
おみくじ API
JSON形式でおみくじの結果を返す
返すようにしました。
レスポンスヘッダとして
Content-Type: application/json; charset=utf-8も返すようにしています。正月(1/1-1/3)だけ大吉にする
現在の日付が 1/1-1/3 の場合に true を返すメソッド
datehelper.IsDuringTheNewYear()を作成し、dojo3/kadai4/hioki-daichi/datehelper/datehelper.go
Lines 12 to 24 in f653008
dojo3/kadai4/hioki-daichi/datehelper/datehelper_test.go
Lines 9 to 42 in f653008
main からそのメソッドを呼び、返り値が true の場合は大吉を返すようにしました。
dojo3/kadai4/hioki-daichi/main.go
Lines 35 to 39 in f653008
ハンドラのテストを書いてみる
以下に書きました。
dojo3/kadai4/hioki-daichi/main_test.go
Lines 12 to 144 in f653008
補足
curl -s https://raw.githubusercontent.com/gopherdojo/dojo3/kadai4-hioki-daichi/kadai4/hioki-daichi/coverage.html -o /tmp/coverage-hioki-daichi.html && open /tmp/coverage-hioki-daichi.html工夫点
name クエリパラメータ
指定した name クエリパラメータの値を JSON の name メンバーとして返すようにしました。
33 文字以上指定された場合はバリデーションエラーとし、
ステータスコード 400 で返すようにしてみました。