<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>It looks okay actually, documentation:</p>
    <p>"If an <code>auto</code> action returns 0, any remaining actions
      will be skipped, except for <code>end</code>".</p>
    <p>It goes directly to end. You should restructure your code
      probably, so that the main handling doesn't happen in end. You can
      also use detach if you want. Also you may want to use the existing
      plugins for Authentication.</p>
    <p><br>
    </p>
    <p>Best<br>
    </p>
    <div class="moz-cite-prefix">On 2017-04-16 08:15, Rajesh Kumar
      Mallah wrote:<br>
    </div>
    <blockquote
      cite="mid:0433a302-6f5d-4ab5-a7cb-a782e7e4a7a7@mtasv.net"
      type="cite">
      <pre wrap="">

Hi ,

I want to return HTTP Status 401 along with a body indicating
the friendly description from my auto method.


so i have below in my auto:
=====================================================
sub auto :Private {
        my ( $self, $c ) = @_;
        my $path = $c-&gt;request-&gt;path ;

        if ($path !~ /login.html/ &amp;&amp; ! $c-&gt;session-&gt;{username}) {
                 $c-&gt;log-&gt;warn('*** Not logged in Authorized ****');
                 $c-&gt;response-&gt;status(401);
                 $c-&gt;response-&gt;body(qq{Sorry please login to access this
resource});
                 return 0;
        }
        return 1;
}

======================================================


However the request proceeds to other part of the chain
and does things which are not required.


===========================================================



[info] *** Request 1 (0.003/s) [839042] [Sun Apr 16 05:23:25 2017] ***
[debug] Path is "/api/rest/articlearticle/list_objects"
[debug] "GET" request for "api/rest/zingyhomes/article_article/" from
"127.0.0.1"
[debug] Query Parameters are:
.-------------------------------------+--------------------------------------.
| Parameter                           | Value                             
  |
+-------------------------------------+--------------------------------------+
| _                                   | 1492317689850                     
  |
| callback                            |
jQuery31001955130972547411_14923176- |
|                                     | 89849                             
  |
| list_count                          | 5                                 
  |
| list_offset                         | 0                                 
  |
'-------------------------------------+--------------------------------------'
[debug] Created session "37077cb431fb8502ac220d4c624b1db2b1217de7"
[warn] *** Not logged in Authorized ****
[debug] end subroutine.
[debug] Response Code: 401; Content-Type: unknown; Content-Length: unknown
[info] Request took 0.069336s (14.423/s)
.------------------------------------------------------------+-----------.
| Action                                                     | Time      |
+------------------------------------------------------------+-----------+
| /api/rest/articlearticle/begin                             | 0.057763s |
| /auto                                                      | 0.005666s |
&lt;---- I want to break
| /api/rest/articlearticle/end                               | 0.000543s |
      here :-(
|  -&gt; /api/rest/articlearticle/serialize                     | 0.000162s |
'------------------------------------------------------------+-----------'

=================================================================================


Previous discussions has been there
but it did not help me:

<a class="moz-txt-link-freetext" href="http://grokbase.com/t/sc/catalyst/055r77h11s/returning-false-in-auto-action">http://grokbase.com/t/sc/catalyst/055r77h11s/returning-false-in-auto-action</a>
<a class="moz-txt-link-freetext" href="http://grokbase.com/t/sc/catalyst/083ev978bd/again-die-in-an-action-chain-does-not-break-the-chain">http://grokbase.com/t/sc/catalyst/083ev978bd/again-die-in-an-action-chain-does-not-break-the-chain</a>


is there anything to halt the request after the appropriate
HTTP Status  and
Headers      and
Body

as been setup.


Regds
Rajesh Kumar Mallah.














_______________________________________________
List: <a class="moz-txt-link-abbreviated" href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a>
Listinfo: <a class="moz-txt-link-freetext" href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a>
Searchable archive: <a class="moz-txt-link-freetext" href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a>
Dev site: <a class="moz-txt-link-freetext" href="http://dev.catalyst.perl.org/">http://dev.catalyst.perl.org/</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>