{"id":180941,"date":"2013-05-26T05:20:03","date_gmt":"2013-05-26T01:20:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=180941"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=180941","title":{"rendered":"<span class=\"post_title\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 RESTful \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 AngularJS<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, <a href=\"http:\/\/www.bennadel.com\/blog\/2432-Applying-A-Cached-Response-To-An-AngularJS-Resource.htm\">\u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 $resource \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u0434\u043e\u043c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u043c API<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 CRUD \u043f\u043e \u0441\u0435\u0442\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e. \u041d\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f RESTful \u0440\u0435\u0441\u0443\u0440\u0441\u0430, \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 CRUD (\u0442. \u0435. \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u0447\u0442\u0435\u043d\u0438\u044f, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f)? \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 RESTful \u00ab\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438\u00bb.<a name=\"habracut\"><\/a><\/p>\n<p>  \u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441\u043e <a href=\"http:\/\/www.bennadel.com\/blog\/2324-REST-API-Design-Rulebook-By-Mark-Masse.htm\">\u0421\u0432\u043e\u0434\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b \u043f\u043e REST API \u041c\u0430\u0440\u043a\u0430 \u041c\u0430\u0441\u0441\u0435<\/a>, \u0435\u0441\u0442\u044c \u0447\u0435\u0442\u044b\u0440\u0435 \u0430\u0440\u0445\u0435\u0442\u0438\u043f\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u0430:<\/p>\n<ul>\n<li><b>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442<\/b> \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u0430.<\/li>\n<li><b>\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f<\/b> \u2014 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/li>\n<li><b>\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/b> \u2014 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435.<\/li>\n<li><b>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440<\/b> \u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<\/li>\n<\/ul>\n<p>  \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0438 \u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043b\u0430\u0433\u043e\u043b\u044b \u0432 HTTP \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c, \u043d\u043e \u0434\u043b\u044f \u0437\u0430\u0443\u0440\u044f\u0434\u043d\u044b\u0445 CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b. \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b:<\/p>\n<ul>\n<li>\/messages<\/li>\n<li>\/messages\/4<\/li>\n<\/ul>\n<p>  \u0418\u043c\u0435\u044f \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 (\u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441) \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 (\u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0441\u0443\u0440\u0441\u0430), \u043a\u0430\u043a \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043e\u0431 \u043e\u0447\u0438\u0441\u0442\u043a\u0435 \u0432\u0441\u0435\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439? \u0418\u043b\u0438, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u0430\u0440\u0445\u0438\u0432? CRUD \u043d\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c. \u041d\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430:<\/p>\n<ul>\n<li>\/messages\/<b>clear-all<\/b><\/li>\n<li>\/messages\/4\/<b>archive<\/b><\/li>\n<\/ul>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u00abclear-all\u00bb \u0438 \u00abarchive\u00bb \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u041d\u0430\u0447\u0430\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0441\u0445\u0435\u043c\u0435 URL, \u0438\u043c\u0435\u044e\u0449\u0435\u0439 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0430\u0440\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c. $resource \u0438\u0437 \u0410\u043d\u0433\u0443\u043b\u044f\u0440\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u00ab\u0443\u043c\u043d\u044b\u0445\u00bb \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0410\u043d\u0433\u0443\u043b\u044f\u0440\u0430 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0448 \u0440\u0435\u0441\u0443\u0440\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d:<\/p>\n<ul>\n<li>\/messages\/:id\/:controller <\/li>\n<\/ul>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e, \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u043f\u0435\u0440\u0432\u043e\u0433\u043e URL-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. \u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u00ab:id\u00bb \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440? \u0418\u043b\u0438 \u044d\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 ID \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430?<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0447\u0430\u0441\u0442\u0438 URL \u0448\u0430\u0431\u043b\u043e\u043d\u0430:<\/p>\n<ul>\n<li>\/messages\/:listController:id\/:docController <\/li>\n<\/ul>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u0430 URL \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<ul>\n<li>:listController<\/li>\n<li>:id<\/li>\n<\/ul>\n<p>  \u041f\u043e\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u0430\u043a \u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442 RESTful-\u0440\u0435\u0441\u0443\u0440\u0441 \u0434\u043e\u043b\u0436\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e, \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0434\u0435\u043c\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0441\u0443\u0440\u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435:<\/p>\n<pre><code class=\"html\">&lt;!doctype html&gt; &lt;html ng-app=&quot;Demo&quot;&gt; &lt;head&gt;     &lt;meta charset=&quot;utf-8&quot; \/&gt;     &lt;title&gt; \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 RESTful \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 AngularJS&lt;\/title&gt;       &lt;!--         \u0422. \u043a. \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438         AngularJS \u0438 ngResource \u043c\u043e\u0434\u0443\u043b\u0438.     --&gt;     &lt;script type=&quot;text\/javascript&quot; src=&quot;..\/angular-1.0.2\/angular.js&quot;&gt;&lt;\/script&gt;     &lt;script type=&quot;text\/javascript&quot; src=&quot;..\/angular-1.0.2\/angular-resource.js&quot;&gt;&lt;\/script&gt;     &lt;script type=&quot;text\/javascript&quot;&gt;             \/\/ \u0413\u043e\u0432\u043e\u0440\u0438\u043c \u0410\u043d\u0433\u0443\u043b\u044f\u0440\u0443 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c ngResource \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439          \/\/ \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.         var app = angular.module( &quot;Demo&quot;, [ &quot;ngResource&quot; ] );           \/\/ \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 app \u0433\u043e\u0442\u043e\u0432\u043e.         app.run(             function( $resource ) {                     \/\/ \u041f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439                 \/\/ \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043a\u0430\u043a get() \u0438 query(), \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430                 \/\/ \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445 HTTP. \u041d\u043e \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c RESTful                 \/\/ \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e                 \/\/ \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 CRUD.                 var messages = $resource(                     &quot;.\/api.cfm\/messages\/:listController:id\/:docController&quot;,                     {                         id: &quot;@id&quot;,                         listController: &quot;@listController&quot;,                         docController: &quot;@docController&quot;                     },                     {                         clear: {                             method: &quot;POST&quot;,                             params: {                                 listController: &quot;clear-all&quot;                             }                         },                         archive: {                             method: &quot;POST&quot;,                             params: {                                 docController: &quot;archive&quot;                             }                         }                     }                 );                   \/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u0440\u0435\u0441\u0443\u0440\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c                 \/\/ \u0435\u0433\u043e \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438.                   \/\/ GET \u0431\u0435\u0437 ID.                 messages.query();                   \/\/ POST \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0430.                 messages.clear();                   \/\/ GET \u0441 ID.                 messages.get(                     {                         id: 4                     }                 );                   \/\/ POST \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430.                 messages.archive(                     {                         id: 8                     }                 );               }         );       &lt;\/script&gt; &lt;\/head&gt; &lt;body&gt;     &lt;!--  \u041d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u0439. --&gt; &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u043e\u0439 \u0430\u043d\u0433\u0443\u043b\u044f\u0440\u043e\u0432\u0441\u043a\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438:<\/p>\n<ul>\n<li>:ListController \u2013 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/li>\n<li>:DocController \u2013 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/li>\n<\/ul>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0448\u0435 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0435\u0441\u0443\u0440\u0441\u0430, \u0442\u043e, \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435, \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u0430\u043c:<\/p>\n<ul>\n<li>GET <a href=\"http:\/\/...\/api.cfm\/messages\">&#8230;\/api.cfm\/messages<\/a><\/li>\n<li>POST <a href=\"http:\/\/...\/api.cfm\/messages\/clear-all\">&#8230;\/api.cfm\/messages\/clear-all<\/a><\/li>\n<li>GET <a href=\"http:\/\/...\/api.cfm\/messages\/4\">&#8230;\/api.cfm\/messages\/4<\/a><\/li>\n<li>POST <a href=\"http:\/\/...\/api.cfm\/messages\/8\/archive\">&#8230;\/api.cfm\/messages\/8\/archive<\/a><\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b URL-\u0430\u0434\u0440\u0435\u0441\u0430 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 REST. \u041a\u0430\u0439\u0444!<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0432\u043e\u0442 \u0444\u0430\u0439\u043b API \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"html\">&lt;!--- \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u044b\u0440\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d. ---&gt; &lt;cfset resourcePath = cgi.path_info \/&gt;     &lt;!---     \u041f\u0420\u0418\u041c\u0415\u0427\u0410\u041d\u0418\u0415: \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e ColdFusion 10 \u043f\u043e\u0434\u0432\u0438\u0441, \u043f\u043e\u043a\u0430 \u044f \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043b\u0430 POST. \u041d\u0435 \u0437\u043d\u0430\u044e, \u043f\u043e\u0447\u0435\u043c\u0443. ---&gt; &lt;cfif ( cgi.request_method neq &quot;GET&quot; )&gt;       &lt;cfset requestBody = getHTTPRequestData().content \/&gt;   &lt;\/cfif&gt;     &lt;!---    \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0448\u0435\u043b, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430  \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438. ---&gt; &lt;cfif reFind( &quot;^\/messages$&quot;, resourcePath )&gt;       &lt;cfset response = &quot;GET without ID.&quot; \/&gt;   &lt;cfelseif reFind( &quot;^\/messages\/clear-all$&quot;, resourcePath )&gt;       &lt;cfset response = &quot;POST with clear-all Controller.&quot; \/&gt;   &lt;cfelseif reFind( &quot;^\/messages\/\\d+$&quot;, resourcePath )&gt;       &lt;cfset response = &quot;GET with ID.&quot; \/&gt;   &lt;cfelseif reFind( &quot;^\/messages\/\\d+\/archive+$&quot;, resourcePath )&gt;       &lt;cfset response = &quot;POST with archive controller&quot; \/&gt;   &lt;cfelse&gt;       &lt;cfset response = &quot;Hmm, couldn't match resource.&quot; \/&gt;   &lt;\/cfif&gt;     &lt;!---      \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 JSON. \u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c. ---&gt; &lt;cfset serializedResponse = serializeJSON( response ) \/&gt;   &lt;!--- \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u0443\u0442\u0438. ---&gt; &lt;cfheader     name=&quot;X-Debug-Path&quot;     value=&quot;#cgi.path_info#&quot;     \/&gt;   &lt;!--- \u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u043f\u043e\u0442\u043e\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a \u043a\u043b\u0438\u0435\u043d\u0442\u0443. ---&gt; &lt;cfcontent     type=&quot;application\/json&quot;     variable=&quot;#charsetDecode( serializedResponse, 'utf-8' )#&quot;     \/&gt; <\/code><\/pre>\n<p>  \u041f\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c, ColdFusion 10 \u0437\u0430\u0432\u0438\u0441\u0430\u043b \u043f\u0440\u0438 POST \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445, \u043f\u043e\u043a\u0430 \u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u043b \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u0435\u043b\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e getHttpRequestData()). \u0422\u0430\u043a\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u0442\u043e\u043b\u044c\u043a\u043e, \u0435\u0441\u043b\u0438 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b\u043e JSON (JavaScript Object Notation) \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u043e\u0433\u0434\u0430 \u043e\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0443\u0441\u0442\u044b\u043c, \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0432\u0438\u0441. \u041d\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0434\u043e\u0441\u043a\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043d\u0435 \u0437\u043d\u0430\u044e, \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u0441\u043c\u044b\u0441\u043b, \u043e\u0434\u043d\u0430\u043a\u043e, \u0437\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e ColdFusion 9 \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435 \u0432\u044b\u0442\u0432\u043e\u0440\u044f\u0435\u0442.<\/p>\n<p>  <a href=\"http:\/\/www.bennadel.com\/blog\/2433-Using-RESTful-Controllers-In-An-AngularJS-Resource.htm\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b<\/a>    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/180941\/\"> http:\/\/habrahabr.ru\/post\/180941\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, <a href=\"http:\/\/www.bennadel.com\/blog\/2432-Applying-A-Cached-Response-To-An-AngularJS-Resource.htm\">\u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 $resource \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u0434\u043e\u043c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u043c API<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 CRUD \u043f\u043e \u0441\u0435\u0442\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e. \u041d\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f RESTful \u0440\u0435\u0441\u0443\u0440\u0441\u0430, \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 CRUD (\u0442. \u0435. \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u0447\u0442\u0435\u043d\u0438\u044f, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f)? \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0410\u043d\u0433\u0443\u043b\u044f\u0440 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 RESTful \u00ab\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438\u00bb.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-180941","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/180941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180941"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/180941\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}