Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails 5 で作る RESTful API 速習会 / Rails RESTful API

Altech
April 19, 2017

Rails 5 で作る RESTful API 速習会 / Rails RESTful API

Altech

April 19, 2017
Tweet

More Decks by Altech

Other Decks in Programming

Transcript

  1. γΰτͰίίϩΦυϧ • Sohei Takeno / @Altech_2015 • 2016೥4݄ʹ Wantedly ʹΤϯδχΞͱͯ͠ೖࣾ

    • Wantedy Visit ʹؔΘ͍ͬͯΔ • άϩʔε ― Push௨஌΍ϝʔϧͷσβΠϯվળɾνϡʔχϯάɺͦͷଞ UI ςετ • αʔϏε։ൃج൫ͷ੔උ ― BigQuery ಋೖ, σʔλղੳδϣϒγεςϜɺPush௨஌ج൫ • Ϛονϯάվળ ― ืूΛ୳͢ػೳʢϑΟϧλɾݕࡧʣͷϩδοΫˍUIվળ • ωΠςΟϒΞϓϦ޲͚ͷ API ࡞੒ ࣗݾ঺հ
  2. γΰτͰίίϩΦυϧ • api/v1 ͱ͍͏ API namespace ͕ݩʑ͋ͬͨ • ը໘ͱAPI͕ີ݁߹͍ͯͨ͠ʢ؇͍ 1screen

    - 1 request ํࣜʣ • දࣔ଎౓Λॏࢹ • ໰୊఺ɿ • νʔϜߏ੒ͷมԽʹґΔɺը໘ͱີ݁߹ʹىҼ͢Δੜ࢈ੑ௿Լ • ϓϩτίϧ͕ͳ͍ʢϨεϙϯεͷܗࣜΛͲ͏͢Δ͔Λຖճ֬ೝʣ ಈػ
  3. γΰτͰίίϩΦυϧ • RESTful ͳ API ʹΞʔΩςΫνϟΛมߋ • ϓϩτίϧͷنఆ • →

    api/v2 ͱͯ͠࡞੒ • ʢ஫ɿ௨ৗͷόʔδϣχϯάతͳ࢖͍ํͱ͸ҟͳΔʣ ղܾํ๏
  4. γΰτͰίίϩΦυϧ • νʔϜͷϓϥοτϑΥʔϜ͝ͱͷ෼୲ํ๏ • Web ͱΞϓϦͷϓϩάϥϚ͸Ұக͢Δͷ͔ɺ͠ͳ͍ͷ͔ • νʔϜͷαʔϏε։ൃͷମ੍ • ผʑʹػೳΛ࣮૷͍ͯ͘͠ͷ͔ɺ౷Ұͯ͠ਐΊ͍ͯ͘ͷ͔ɺWeb

    ͕ઌߦ͢Δͷ͔ɺΞϓϦ͕ઌߦ͢Δͷ͔ • ϢʔβʔʢiOS, Android ϓϩάϥϚʣͷϦςϥγʔ • ΫϥΠΞϯτʢiOS ΞϓϦ, Android ΞϓϦʣͷઃܭ • ΞʔΩςΫνϟ͸ʁViewModel ૚Έ͍ͨͳͷΛೖΕΔ͜ͱ͸Մೳ͔ʁ • ͳͲ… લఏɿRESTful ͔ͩΒྑ͍Θ͚Ͱ͸ͳ͍ API ͷΞʔΩςΫνϟΛܾఆ͢Δࡍʹґଘͨ͜͠ͱͷྫɿ
  5. γΰτͰίίϩΦυϧ • Wantedly Visit ॳͷ iOS ΞϓϦϦϦʔε • ಉ͡ҰਓͷϓϩάϥϚ͕ iOS

    ΋ Web ΋ॻ͘ • Server-Client = 1 : 1 v1࡞੒࣌ͷ։ൃମ੍ʢ2014/5ʣ
  6. γΰτͰίίϩΦυϧ • Web, iOS, Android ͦΕͧΕҰਓʢUser Growth νʔϜʣ • Web

    ͸ Web Ͱ iterative ʹϦϦʔεɾݕূͯ͠αʔϏε վળΛ͍ͯ͘͠ͷ͕ϝΠϯλεΫ • Web ͕ઌߦ͢Δ։ൃͳͷͰ API Λॻ࣌͘Ϟσϧ͸͋Δఔ ౓Ͱ͖͍ͯΔঢ়ଶ • ʢͪͳΈʹݱࡏ͸ Web, iOS ͱ΋ʹೋਓʹʣ v2࡞੒࣌ͷ։ൃମ੍ʢ2017/1ʣ
  7. γΰτͰίίϩΦυϧ • ը໘ͷৄࡉʹ͍͍ͪͪ Web ͷΤϯδχΞ͕ؔ஌͍ͯͯ͠͸ੜ࢈ੑ͕Լ͕Δ • มߋͷࡍ΋ɺطʹ͋Δը໘ͷ஌͕ࣝલఏʹͳΔͷͰɺ೉͍͠ • ίϛϡχέʔγϣϯͷ಺༰͕σʔλʹϑΥʔΧε͞ΕΔ •

    ϞσϧʹରԠͯ͠ΤϯυϙΠϯτͱίϯτϩʔϥΛ࡞͍ͬͯ͘ͷͰɺมߋ ͢΂͖Օॴ͕໌֬ • ઃܭʹ੍໿͕ՃΘΔͷͰɺΑΓͦ͜ʹϑΥʔΧεͨ͠࢖͍΍͍͢ϓϩτί ϧ΍ϥΠϒϥϦΛಋೖͰ͖ΔΑ͏ʹͳΔ ಋೖഎܠ·ͱΊ api/v2 ͷಋೖ