最近はバックエンドの開発をしている筆者です
雰囲気でcurlを叩いてたのでどんなオプションがあるのか調べていたところ、クイズ形式みたいなサイトが紹介されていたのでやってみました。
それが http://challenge-your-limits.herokuapp.com/ というサイトです。
表示通りにcurlを叩いてみると “Almost! It’s not GET. Keep trying.” のように言われるので、GET以外のHTTP Methodで試してみる…みたいに進めていくとやがてクリアできます。
まとめると以下の試行錯誤という感じですね
- リクエストを行う
- レスポンスのメッセージに次の指示やリクエストが通らなかった理由が記載されている
内容としては非常にシンプルだったので、最近ハマっているPlantUMLでシーケンス図に起こしてみました(とはいえ自分とアクセス先のやりとりしか無いわけですが)
Validation Errorの箇所はエラー文言読めよという感じですね
PlantUMLをどう書いているのかのサンプルは↓
@startuml challenge-your-limits.herokuapp.com
!include pu.conf
title challenge-your-limits.herokuapp.com
header [nixiy]
' config
actor My
box endpoint
participant ChallengeYourLimits
end box
' graph
My -> ChallengeYourLimits: Access
My <-- ChallengeYourLimits: Please call my APIs.\n$ curl http://challenge-your-limits.herokuapp.com/call/me
==curl==
group call/me
My -> ChallengeYourLimits: $ curl http://challenge-your-limits.herokuapp.com/call/me
My <-- ChallengeYourLimits: {"message":"Almost! It's not GET. Keep trying."}
note right My: 🔵POST試してみる
My -> ChallengeYourLimits: curl -X POST http://challenge-your-limits.herokuapp.com/call/me/
My <-- ChallengeYourLimits: {"message":"Great! Please register as /challenge_users"}
end
group challenge_users
My -> ChallengeYourLimits: curl http://challenge-your-limits.herokuapp.com/challenge_users
My <-- ChallengeYourLimits: {"message":"GET? No. No."}%
note right My: ❌PUT試してみる
My -> ChallengeYourLimits: curl -X PUT http://challenge-your-limits.herokuapp.com/challenge_users
My <-- ChallengeYourLimits: {"message":"No No. Not this way"}%
note right My: ❌POST試してみる
My -> ChallengeYourLimits: curl -X POST http://challenge-your-limits.herokuapp.com/challenge_users
My <-- ChallengeYourLimits: {"message":"Validation Error, [:name, \"__**can't be blank**__\"]"}%
note right My: ❌-d リクエストパラメータ\n-H リクエストヘッダを埋めてみる
My -> ChallengeYourLimits: curl -X POST http://challenge-your-limits.herokuapp.com/challenge_users -d 'hoge' -H 'hoge'
My <-- ChallengeYourLimits: {"message":"Validation Error, [:name, \"__**can't be blank**__\"]"}%
note right My: 🔸パラメータのnameを埋めてみる
My -> ChallengeYourLimits: curl -X POST http://challenge-your-limits.herokuapp.com/challenge_users -d 'name=hoge
My <-- ChallengeYourLimits: {"message":"Validation Error, [:email, \"can't be blank\"]"}%
note right My: 🔵バリデーションに引っかからないようにメルアドを指定
My -> ChallengeYourLimits: curl -X POST http://challenge-your-limits.herokuapp.com/challenge_users -d 'name=hoge&email=hoge@hoge.com.com'
My <-- ChallengeYourLimits: {"message":"Thanks! Please access to http://challenge-your-limits.herokuapp.com/challenge_users/token/xYN4W-hgJBw from your web browser."}%
end
==Browser==
My -> ChallengeYourLimits: Access http://challenge-your-limits.herokuapp.com/challenge_users
note over ChallengeYourLimits: 🔵Clear
My <-- ChallengeYourLimits: Wow! You must be a great software engineer!
@enduml
なんか配色がいい感じだなとおもったら以下を使ってみて下さい(PRも募集しています)
[blogcard url=”https://github.com/nixiy/FreshPlantUML”]


