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

Simple Rest API

2168461de6bab44e564c2d8015ee830c?s=47 hfcorriez
December 24, 2014

Simple Rest API

Describe How to make the Simple Rest API

2168461de6bab44e564c2d8015ee830c?s=128

hfcorriez

December 24, 2014
Tweet

Transcript

  1. 简单的 Rest API

  2. None
  3. None
  4. 何谓 HTTP (&5QBUIGJMFIUNM)551 6TFS"HFOU4BGBSJ "VUIPSJ[BUJPOBQJYYYYYYY $PPLJFYYYYYYYY [blank line here] )5510,

    %BUF'SJ %FD(.5 $POUFOU5ZQFUFYUIUNM $POUFOU-FOHUI IUNM CPEZ I)BQQZ/FX.JMMFOOJVNI NPSFGJMFDPOUFOUT  
  5. 垃圾设计

  6. 好的设计

  7. Simple

  8. None
  9. 简单分解 c νಆ 4FDVSJUZ  c ਫ਼ࣥ &OEQPJOU  c

    )551ٚم 7FSCT  c ݖੲ 'JMUFST  c ๨҆ )FBEFST  c հ༂ԩ৘ &SSPSIBOEMJOH  c ْ߭ࢲݔ 3FTQPOTF  c ಪᆣč"VUIĎ
  10. 安全 c ࣐ਈ൐ႨIUUQT c ൐Ⴈ0"VUIa#BTJD"VUI 5PLFO֩ಪᆣ c ष٢֥"1*ླေቓ௔Ց॥ᇅބ*1॥ᇅ

  11. 路径 c ࣐ਈ൐Ⴈ׿৫֥თ଀BQJQVCVJN c ࣐ਈ൐ႨջϱЧݼ֥ਫ਼ࣥđбೂWđBQJW  c ሧჷ଀൐ႨگඔDBUT c ҂ေ൐Ⴈջ۬ൔֹ֥ᆶDBUTKTPO

    https://api.pubu.im/v1/cats ၂۱ປૅ֥ਫ਼ࣥ
  12. 方法 Resource POST GET PUT update DELETE /cats Create cat

    List cats Bulk update cats Delete all dogs /articles/1234 - Show cat with ID Update if exists Delete with ID /cats/OP - List cats with operation Bulk update with Operation - /cats/1234/OP - Show a cat with Operation Update with Operation -
  13. 过滤 c ൐ႨRVFSZTUSJOHটݖੲDBUT UZQFUFYU c ٳ်ބնཬҐႨ๝ഈ֥ٚൔDBUT QBHFTJ[F c ႳѓٚൔᆦӻDBUT GSPNTJ[F

    c ᆷקሳ؍DBUT GJFMETJE OBNF
  14. 头部 c ކ৘֥൐Ⴈሑ෿઒ c ކ৘֥॥ᇅߏթ c ކ৘֥ഡᇂᆦӻ۬ൔ c ष٢"1*ླေᆦӻॴთטႨ Status

    code Description 200 OK 201 Created 301 Move Temporature 302 Move Permalink 401 Not Authorized 403 Fobidden 404 Not Found
  15. 错误处理 c ൐ႨY Y֥ሑ෿઒ c ࣐ॖି֥૭ඍհ༂ c षؿߌ࣢༯ൻԛհ༂ט൫ྐ༏ c ۷؟ྐ༏ֹᆶᆷཟ

    \ DPEF  NFTTBHFo$BUJTBMSFBEZEFBEp  NPSF*OGPoIUUQTBQJQVCVJNWDBUTEFBE@JOGPp ^
  16. 返回结果 c ൐Ⴈӈ࡮֥ࢲܒ߄۬ൔYNMaKTPOaKTPOQ c ы௜ࢲܒ۷ൡކࡥֆ֥ཛଢđళสࢲܒ۷ൡކگᄖ֥ཛଢ c ൈࡗ൐Ⴈᆜྙ֥ݸ૰ඔ c DBNM$BTFބVOEFSTDPSF@DBTF࿊ᄴીପહᇗေ c

    ҂ေᇗگ૭ඍ*%bDBU*EJE \ JE  OBNFo-VDZp  BHF  DSFBUFE"U ^ \ NFUB\l^  EBUB\ JE  OBNFo-VDZp  BHF  DSFBUFE"U ^ ^
  17. 认证 c ࣐ਈ҂൐Ⴈ4FTTJPOಪᆣ c ༀс҂ေ൐Ⴈૼ໓ૡ઒ቓູ֨੣௝ ᆣ c ष٢"1*࣐ਈ൐Ⴈ0"VUI

  18. Simple is not easy!