差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

java:web:restapi [2017/09/13 00:47]
tony [Resource]
java:web:restapi [2023/06/25 09:48]
行 1: 行 1:
-{{tag>​rest}} 
-====== Rest API ====== 
-===== Introduction ===== 
-原本就有接觸過Facebook Graph API,因工作關係接觸到Rest,所以學習起來比較不陌生。因為網路資料相當豐富,我只記錄些自己容易忘記的部分。 
-===== Articles ===== 
-  * [[java:​web:​restapi:​X-HTTP-Method-Override Filter|Incorrect response(401) when using X-HTTP-Method-Override]] 
-  * [[java:​web:​restapi:​http_method_cant_make_sense|Http Method無法表達出某些動作]] 
-===== Firewall issue of HTTP Delete & Put operations ===== 
-HTTP Delete與Put操作可能會被防火牆阻擋,經過Study有三種替代方案。 
-  - Http POST + method=delete:​ 增加method參數去描述行為。(可參考Spring的HiddenHttpMethodFilter) 
-  - Http POST + {id}/​delete:​ 在URI多增加操作。 
-  - Request with Header X-HTTP-Method-Override=DELETE:​ 透過Header置換操作。(參考[[https://​www.isostech.com/​blogs/​web-application-development/​put-delete-requests-yui3-spring-mvc/​|link]]) 
-個人覺得第三種做法比較正規些,目前知道[[https://​www.firebase.com/​docs/​rest/​api/​|firebase]]、[[http://​docs.oracle.com/​cloud/​latest/​marketingcs_gs/​OMCAB/​Developers/​GettingStarted/​API%20requests/​http-request-headers.htm|oracle的OMCAB]]與[[https://​www-01.ibm.com/​support/​knowledgecenter/​SSFPJS_8.5.6/​com.ibm.wbpm.ref.doc/​rest/​repository/​index.htm|IBM Business Process Manager]]都用這做法。 
-===== Terms ===== 
-==== Hypermedia Control ==== 
-Richardson Maturity Model所定義的等級3。主要有兩個好處:​ 
-  - 如果使用者是根據Hypermedia link做操作,Server是可以自行修改URI而不需要通知使用者。 
-  - 使用者可以根據Hypermedia link知道: 接下來可以做什麼。 
-而Richardson提到,Hypermedia link該怎麼呈現並沒有一定規範,他是使用rel描述關係,uri描述連結的方式:​ 
-<code html> 
-<link rel = "/​linkrels/​appointment/​cancel"​ 
-        uri = "/​slots/​1234/​appointment"/>​ 
-<link rel = "/​linkrels/​appointment/​addTest"​ 
-        uri = "/​slots/​1234/​appointment/​tests"/>​ 
-<link rel = "​self"​ 
-        uri = "/​slots/​1234/​appointment"/>​ 
-</​code>​ 
-以Richardson的方法而言,他的rel也表達了對應動作。換成PayPal REST Payment API的例子:​ 
-<code cpp> 
-"​links"​ : [{ 
-   "​href"​ : "​https://​api.sandbox.paypal.com/​v1/​payments/​payment/​PAY-2XR800907F429382MKEBWOSA",​ 
-   "​rel"​ : "​self",​ 
-   "​method"​ : "​GET"​ 
-  }, { 
-   "​href"​ : "​https://​api.sandbox.paypal.com/​v1/​payments/​payment/​PAY-2XR800907F429382MKEBWOSA/​execute",​ 
-   "​rel"​ : "​update",​ 
-   "​method"​ : "​POST"​ 
-  } 
- ] 
-</​code>​ 
-PayPal則是多了method去表達對應的HTTP request。 
- 
-===== Resource ===== 
-  * [[https://​spring.io/​understanding/​HATEOAS|HATEOAS]] 
-  * [[http://​martinfowler.com/​articles/​richardsonMaturityModel.html|Richardson Maturity Model]] [[https://​read01.com/​xOL668.html#​.WbVdZLKg-JA|中文]] 
-  * [[http://​www.iana.org/​assignments/​link-relations/​link-relations.xhtml|Well-known Link Relations]] 
-  * [[https://​developer.paypal.com/​docs/​integration/​direct/​paypal-rest-payment-hateoas-links/​|HATEOAS and the PayPal REST Payment API]] 
-  * [[http://​restcookbook.com/​|Rest Cookbook]] 
-  * [[http://​stackoverflow.com/​questions/​1828790/​restful-put-and-delete-and-firewalls|RESTful PUT and DELETE and firewalls]] 
-  * [[http://​www.hanselman.com/​blog/​HTTPPUTOrDELETENotAllowedUseXHTTPMethodOverrideForYourRESTServiceWithASPNETWebAPI.aspx|HTTP PUT or DELETE not allowed? Use X-HTTP-Method-Override for your REST Service with ASP.NET Web API]] 
-  * [[http://​www.slideshare.net/​josdirksen/​rest-from-get-to-hateoas|REST:​ From GET to HATEOAS]] 
-  * [[http://​farazdagi.com/​blog/​2014/​rest-long-running-jobs/​|Long running jobs of Rest]] 
-  * [[http://​stackoverflow.com/​questions/​15365660/​spring-mvc-and-x-http-method-override-parameter|http-method-override of Spring]] 
-  * [[https://​www.isostech.com/​blogs/​web-application-development/​put-delete-requests-yui3-spring-mvc/​|PUT and DELETE Requests with YUI3 and SpringMVC]] 
-  * [[http://​stackoverflow.com/​questions/​2427518/​which-http-redirect-status-code-is-best-for-this-rest-api-scenario|Which HTTP redirect status code is best for this REST API scenario?]] 
-  * [[http://​www.slideshare.net/​ewolff/​rest-vs-messaging-for-microservices|REST VS JMS of microservices]] 
-  * [[http://​tatiyants.com/​using-oauth-to-protect-internal-rest-api/​|using-oauth-to-protect-internal-rest-api]] studying.. 
-  * [[https://​community.alfresco.com/​docs/​DOC-5717-32-rest-api-group-service#​w_rootgroupscollection|Alfresco - Group設計]] 
-  * [[https://​stackoverflow.com/​questions/​207477/​restful-url-design-for-search|Design for search]] 
-  * [[https://​cwiki.apache.org/​confluence/​display/​solr/​JSON+Request+API|使用JSON Request Body發request]] 
-  * [[http://​www.computersciencezone.org/​50-most-useful-apis-for-developers/​|50 Most Useful APIs for Developers]] 
-  * [[https://​webdam.com/​blog/​top-10-web-apis_bridging-todays-technology/​|top-10-web-apis_bridging-todays-technology]] 
-  * [[https://​gxnotes.com/​article/​29390.html|為什麼基於REST而不是SOAP?​]] 
-  * [[https://​docs.microsoft.com/​en-us/​azure/​architecture/​best-practices/​api-design|Best Practice - Azure]] 
-  * [[http://​www.infoq.com/​cn/​news/​2008/​12/​restapi-must-be-hypertext-driven|restapi-must-be-hypertext-driven]] 
-  * [[https://​www.serviceobjects.com/​resources/​articles-whitepapers/​why-rest-popular|Why REST popular?]] 
-  * [[https://​gxnotes.com/​article/​39086.html|那REST API真的是RPC吗? Roy Fielding似乎想到了]] 
-  * [[https://​www.smashingmagazine.com/​2016/​09/​understanding-rest-and-rpc-for-http-apis/​|Understanding RPC Vs REST For HTTP APIs]] 
-  * [[http://​roy.gbiv.com/​untangled/​2009/​it-is-okay-to-use-post|it-is-okay-to-use-post]] 
-  * [[https://​www.mnot.net/​blog/​2012/​12/​04/​api-evolution|API evolution]] 
-  * [[http://​hypermedia.apievangelist.com/​]] 
-  * [[https://​blog.akana.com/​hypermedia-apis/​|The Movement Towards Hypermedia APIs – Is it Happening?​]] 
-  * [[https://​www.vegaitsourcing.rs/​media-center/​blog/​2015/​04/​hypermedia-driven-restful-web-apis/​|Hypermedia-driven RESTful web APIs]] 
-==== Basic ==== 
-  * [[https://​ihower.tw/​blog/​archives/​6483|HTTP Verbs: 談 POST, PUT 和 PATCH 的應用]] 
-  * [[https://​stackoverflow.com/​questions/​3825990/​http-response-code-for-post-when-resource-already-exists|post with duplicate resource]] 
-  * [[https://​www.infoworld.com/​article/​3206264/​application-development/​how-to-perform-partial-updates-to-rest-web-api-resources.html|How to do partial updates to REST API resources?​]] 
-==== Transaction ==== 
-  * [[http://​www.slideshare.net/​cesare.pautasso/​atomic-transactions-for-the-rest-of-us|Atomic Transactions for the REST of us]] 
-  * [[https://​docs.marklogic.com/​guide/​rest-dev/​transactions|marklogic - REST Application Developer'​s Guide]] 
-  * [[http://​stackoverflow.com/​questions/​147207/​transactions-in-rest|stackoverflow - Transactions in REST?]] 
-==== Client ==== 
-  * [[https://​gist.github.com/​andi-bigswitch/​11070102|Restlet - 使用自己的CertificateManager]] 
-==== Spring ==== 
-  * [[https://​spring.io/​guides/​gs/​rest-service/​|Building a RESTful Web Service]] 
-  * [[https://​spring.io/​guides/​gs/​rest-hateoas/​|Building a Hypermedia-Driven RESTful Web Service]] 
-  * [[http://​stackoverflow.com/​questions/​19767267/​handle-spring-security-authentication-exceptions-with-exceptionhandler|handle-spring-security-authentication-exceptions-with-exceptionhandler]] 
-  * [[https://​spring.io/​guides/​gs/​actuator-service/​|Building a RESTful Web Service with Spring Boot Actuator]]