{"id":292655,"date":"2019-07-28T09:00:07","date_gmt":"2019-07-28T09:00:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=292655"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=292655","title":{"rendered":"API \u043d\u0430 F#. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u043e\u043b\u0435\u0439"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>ASP.NET Core \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a api \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c claim, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u043a \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0440\u043e\u043b\u0435\u0439<br \/>  \u0423 \u044d\u0442\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0435\u0441\u0442\u044c \u043c\u0438\u043d\u0443\u0441\u044b, \u0441\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">[Authorize(Roles = \"Administrator\")] public class AdministrationController : Controller { }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430, \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435\u0445 \u0437\u0430\u0431\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0437\u0430 \u044d\u0442\u043e\u0442 \u043c\u0435\u0441\u044f\u0446 (\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0431\u0430\u0437\u0443 \u0438 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c, \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0434\u0435-\u0442\u043e \u0435\u0441\u0442\u044c), \u044f \u0434\u0435\u043b\u0430\u044e <em>CTRL+N<\/em> \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u0438 \u0438\u0449\u0443 <em>BannedUserHandler <\/em>\u0438\u043b\u0438 <em>IHasInfoAbounBannedUser<\/em> \u0438\u043b\u0438 <em>GetBannedUsersForAdmin<\/em>. <\/p>\n<p>  <\/p>\n<p>\u042f \u043d\u0430\u0445\u043e\u0436\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <em>[Authorize(Roles = &#171;Administrator&#187;)]<\/em>, \u0442\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0432\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f: <\/p>\n<p>  <\/p>\n<p><em>\u0414\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u0435 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">    [Route(\"api\/[controller]\/[action]\")]     public class AdminInfoController1 : ControllerBase     {         private readonly IGetUserInfoService _getInfoAboutActiveUsers;         private readonly ICanBanUserService _banUserService;         private readonly ICanRemoveBanUserService _removeBanUserService;          \/\/ \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0443\u0436\u043d\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c action         public AdminInfoController1(             IGetUserInfoService infoAboutActiveUsers,             ICanBanUserService banUserService,             ICanRemoveBanUserService removeBanUserService)         {             _getInfoAboutActiveUsers = infoAboutActiveUsers;             _banUserService = banUserService;             _removeBanUserService = removeBanUserService;         }          \/\/ actions         \/\/...         \/\/...     }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u0420\u0430\u0437\u043d\u043e\u0441\u0438\u043c \u043f\u043e \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0430\u043c<\/em><\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">    [Route(\"api\/[controller]\/[action]\")]     public class AdminInfoController2 : ControllerBase     {         [HttpPatch(\"{id}\")]         public async Task&lt;ActionResult&lt;BanUserResult&gt;&gt; BanUser(             [FromServices] IAsyncHandler&lt;UserId, BanUserResult&gt; handler,             UserId userId)               =&gt; await handler.Handle(userId, HttpContext.RequestAborted);          [HttpPatch(\"{id}\")]         public async Task&lt;ActionResult&lt;RemoveBanUserResult&gt;&gt; RemoveBanUser(             [FromServices] IAsyncHandler&lt;UserId, RemoveBanUserResult&gt; handler,             UserId userId)              =&gt; await handler.Handle(userId, HttpContext.RequestAborted);     }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435\u043f\u043b\u043e\u0445 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u0430\u043a\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0438\u043c\u0435\u0435\u0442 \u0410\u0434\u043c\u0438\u043d, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u044f \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0431\u0435\u0437 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438<\/p>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0436\u0435 \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u0439, \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u0432 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0430\u0445, \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u0430 \u043c\u043d\u0435, \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u043f\u0440\u0430\u0432\u0434\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0440\u0430\u0437\u0431\u0443\u0445\u0430\u044e\u0442, \u0438\u0445 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0430\u043f\u043a\u0438\/\u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0432 \u043a\u0430\u0436\u0434\u0443\u044e\/\u044b\u0439 \u043a\u043b\u0430\u0434\u0443\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u0438\u0445 \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/p>\n<p>  <\/p>\n<p>\u0423 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a, \u043a\u043e\u0434 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f =&gt; \u0442\u0440\u0430\u0442\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 =&gt; \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<p>  <\/p>\n<p>\u0410 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0443\u043c\u0430\u0442\u044c, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>  <\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e Suave<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0435\u0441\u043b\u0438 routing \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/www.c-sharpcorner.com\/article\/routing-in-suave-io-web-development-with-f-sharp\/\">\u0442\u0430\u043a<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">let webPart =         choose [             path \"\/\" &gt;=&gt; (OK \"Home\")             path \"\/about\" &gt;=&gt; (OK \"About\")           path \"\/articles\" &gt;=&gt; (OK \"List of articles\")           path \"\/articles\/browse\" &gt;=&gt; (OK \"Browse articles\")           path \"\/articles\/details\" &gt;=&gt; (OK \"Content of an article\")       ]   <\/code><\/pre>\n<p>  <\/p>\n<p>&#187;&gt;=&gt;&#187; \u2014 \u0447\u0442\u043e \u044d\u0442\u043e? \u0423 \u044d\u0442\u043e\u0439 \u0448\u0442\u0443\u043a\u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u043d\u043e \u0435\u0433\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u043d\u0438 \u043d\u0430 \u0433\u0440\u0430\u043c\u043c \u043d\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u043a \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044e, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430, \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0448\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d pipeline \u043e\u0442 Suave, \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 Giraffe (\u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0439), \u0435\u0441\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">type WebPart = HttpContext -&gt; Async&lt;HttpContext option&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>Async \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u043e\u0439 \u0440\u043e\u043b\u0438(\u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442), \u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">HttpContext -&gt; HttpContext option<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <em>HttpContext<\/em>, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 (\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0442\u0435\u043b\u043e, \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430 \u043a\u0443\u043a\u0438, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0440\u0435\u043a\u0432\u0435\u0441\u0442\u0430), \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442, \u0438 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u2014 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432 <em>Some<\/em>, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>None<\/em>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 (<a href=\"https:\/\/github.com\/SuaveIO\/suave\/blob\/c25f6191869f0cff912388422e1f8b443f1699fe\/src\/Suave\/Combinators.fs\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/a>):<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">  \/\/ \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0432 async   let OK s : WebPart =     fun ctx -&gt;            { ctx with response =                { ctx.response with status = HTTP_200.status; content = Bytes s }}            |&gt; Some |&gt; async.Return<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 &#171;\u0437\u0430\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430&#187;, \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u043e\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u043e\u0432\u044b\u0439 response, \u0441 \u0442\u0435\u043b\u043e\u043c \u0438 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c 200, \u0430 \u0432\u043e\u0442 \u044d\u0442\u0430 \u043c\u043e\u0436\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">let path (str:string) ctx =             let path = ctx.request.rawPath             if path.StartsWith str              then ctx |&gt; Some |&gt; async.Return             else async.Return None <\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043d\u0443\u0436\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044d\u0442\u043e <a href=\"https:\/\/github.com\/SuaveIO\/suave\/blob\/e200d29d115ee4a62368310551b58938954f67cb\/src\/Suave\/WebPart.fs\"><em>choose<\/em><\/a> \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u043d\u0435\u0442 Some:<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">let rec choose   (webparts:(HttpContext) -&gt; Async&lt;HttpContext option&gt;) list)  context=               async{              match webparts with                         | [head] -&gt; return! head context                         | head::tail  -&gt;                              let! result = head context                             match result with                             | Some _-&gt; return result                             | None -&gt; return! choose tail context                         | [] -&gt; return None              }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0443 \u0438 \u0441\u0430\u043c\u0430\u044f \u0433\u043b\u0430\u0432\u043d\u0430\u044f, \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f (Async \u043e\u043f\u0443\u0449\u0435\u043d):<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">type WebPartWithoutAsync = HttpContext -&gt; HttpContext option let (&gt;=&gt;) (h1:WebPartWithoutAsync ) (h2:WebPartWithoutAsync) ctx                                      : HttpContext option =  let result = h1 ctx  match result with   | Some ctx' -&gt; h2 ctx'   | None -&gt; None<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Async \u0432\u0435\u0440\u0441\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"haskell\">type WebPart = HttpContext -&gt; Async&lt;HttpContext option&gt; let (&gt;=&gt;) (h1:WebPart ) (h2:WebPart ) ctx : Async&lt;HttpContext option&gt;=   async{    let! result = h1 ctx    match result with     | Some ctx' -&gt; return! h2 ctx'     | None -&gt; return None   } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>&#171;&gt;=&gt;&#187; \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0430 \u0441 \u043b\u0435\u0432\u043e\u0439 \u0438 \u043f\u0440\u0430\u0432\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d \u0438 <em>httpContext<\/em>, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u0441\u0435\u0440\u0432\u0435\u0440 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 HttpContext, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, &#171;&gt;=&gt;&#187; \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439(\u043b\u0435\u0432\u044b\u0439) \u0445\u0435\u043d\u0434\u043b\u0435\u0440, \u0435\u0441\u043b\u0438 \u043e\u043d \u0432\u0435\u0440\u043d\u0443\u043b <em>Some ctx<\/em>, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 ctx \u043d\u0430 \u0432\u0445\u043e\u0434 \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0443.<\/p>\n<p>  <\/p>\n<p>\u0410 \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a (\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439)?<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">GET &gt;=&gt; path \"\/api\" &gt;=&gt; OK<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e &#171;&gt;=&gt;&#187; \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 WebPart \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0443\u044e <em>HttpContext<\/em> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e <em>Async&lt;HttpContext option&gt;<\/em>, \u0430 \u043a\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>Async&lt;HttpContext option&gt;<\/em>?<br \/>  <em>WebPart<\/em>.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e <em>&#171;&gt;=&gt;&#187;<\/em> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u043b\u044f \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0430 WebPart \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>WebPart<\/em>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u043e\u0434\u0440\u044f\u0434, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430.<br \/>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/suave.io\/routing.html\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<p>  <\/p>\n<h3 id=\"pri-chem-tut-roli-i-ogranichenie-dostupa\">\u041f\u0440\u0438 \u0447\u0435\u043c \u0442\u0443\u0442 \u0440\u043e\u043b\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430?<\/h3>\n<p>  <\/p>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u0441\u0442\u0430\u0442\u044c\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0443, \u043a \u043a\u0430\u043a\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043b\u044f \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0440\u043e\u043b\u0438? \u041d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0432 pipeline \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u044b \u0438\u043c\u0435\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/i5\/oh\/zi\/i5ohziec88tovhgpezx11dc0lw0.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0447\u0430\u0441\u0442\u0438\/\u043c\u043e\u0434\u0443\u043b\u0438. \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 <em>AdminPart<\/em> \u0438 <em>AccountPart<\/em> \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u043e\u043b\u0435\u0439, \u043a <em>AccountPart<\/em> \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043a <em>AdminPart<\/em> \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u043c\u0438\u043d, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e chooseP, \u044f \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u043a \u0442\u0438\u043f\u0430\u043c Suave, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 <em>AdminPart<\/em> \u0438 <em>AccountPart<\/em> \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">\/\/ AdminPart    AdminInfo * HttpContext -&gt; Async&lt;(AdminInfo * HttpContext) option&gt; \/\/ AccountPart     AccountInfo* HttpContext -&gt; Async&lt;(AccountInfo * HttpContext) option&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0445\u0435\u043d\u0434\u043b\u0435\u0440 \u0441\u0440\u0430\u0437\u0443 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u043e\u043b\u0438, \u0442\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 <em>AccountPart<\/em> \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0438\u043a\u043d\u0435\u0439\u043c, email, \u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0441\u043e\u0446.\u0441\u0435\u0442\u044c, \u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u043e\u0432 \u043c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439, \u043d\u043e \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043e\u043d \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c? \u041b\u0438\u0431\u043e \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u044b \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u043c(\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e), \u043b\u0438\u0431\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043b\u0435\u043d\u0438\u0432\u044b\u043c(\u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0432 <em>unit -&gt; friends list<\/em>), \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0435 \u043a\u043b\u0430\u0441\u0442\u044c \u0442\u0443\u0434\u0430 <em>IQueryable&lt;Friend&gt;<\/em>, \u043f\u043e\u0442\u043e\u043c\u0443 \u044d\u0442\u043e \u043d\u0435 \u0441\u0435\u0440\u0432\u0438\u0441 \u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0440\u043e\u043b\u044c<\/p>\n<p>  <\/p>\n<p>\u042f \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0432 <em>AdminInfo<\/em> \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u043d\u044b\u0445 \u0438 \u0437\u0430\u0431\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0430\u0434\u043c\u0438\u043d\u043e\u043c, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043c\u043e\u0435\u0433\u043e &#171;\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f&#187; \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u043e\u043b\u044c \u0410\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">   type AdminInfo = {             ActiveUsersEmails: string list             BanUsersEmails : string list                           }     type UserInfo = {             Name:string             Surname:string         }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0447\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <em>Claim<\/em>? \u041c\u043e\u0436\u043d\u043e \u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c <em>User.Claims<\/em> \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435?<\/p>\n<p>  <\/p>\n<p>\u0412 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0432 &#171;\u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u0445&#187;: \u043c\u043e\u0434\u0443\u043b\u044f\u0445, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u043f\u043e \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0430\u043c, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0441\u044f \u0432 \u0442\u043e\u043c \u0436\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435, \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0445\u0435\u043d\u0434\u043b\u0435\u0440 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/p>\n<p>  <\/p>\n<pre><code class=\"haskell\">let AccountPart handler =              let getUserInfo ctx =                  async.Return {Name=\"Al\";Surname=\"Pacino\"}             permissionHandler [User;Admin] getUserInfo  handler<\/code><\/pre>\n<p>  <\/p>\n<p><em>getUserInfo<\/em> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u044f <em>Account<\/em>, \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435(\u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0433\u043e user&#8217;a, admin&#8217;a)<\/p>\n<p>  <\/p>\n<p><em>permissionHandler<\/em> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 jwt token&#8217;a, \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e, \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 WebPart, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 Suave<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/brager17\/RolesApi\/blob\/master\/RolesApi\/Permissions.fs\">github<\/a><br \/>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/461593\/\"> https:\/\/habr.com\/ru\/post\/461593\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>ASP.NET Core \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a api \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c claim, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c \u043a \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0440\u043e\u043b\u0435\u0439<br \/>  \u0423 \u044d\u0442\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0435\u0441\u0442\u044c \u043c\u0438\u043d\u0443\u0441\u044b, \u0441\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">[Authorize(Roles = \"Administrator\")] public class AdministrationController : Controller { }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440.<\/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-292655","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292655","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=292655"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292655\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=292655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=292655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}