title: return a json error in middleware?
body: <p>I'm building an app and I'm using laravel5 as webAPI.
  When the webAPI is in Maintenance Mode, I want to return a json error to app and I will get the status code in app to show a suitable message.</p>
  
  <p>I rewrite the laravel CheckForMaintenanceMode for somereason and registed it in Kernel.</p>
  
  <p>I write </p>
  
  <pre><code>if ($this-&gt;app-&gt;isDownForMaintenance()) {
      $ip = $request-&gt;getClientIp();
      $allowIp = "111.222.333.444";
      if ($allowIp != $ip) {
          return response()-&gt;json(['error' =&gt; "Maintenance!!"], 503);
      }
  }
  return $next($request);
  </code></pre>
  
  <p>But I can get NOTHING in app side.I cannot get the message, the satus....</p>
  
  <p>I writh the same code like <code>return response()-&gt;json(['error' =&gt; "errormessage"], 422);</code> in controller and I can get the message.status.. in app but I cannot do the same thing in a middleware.</p>
  
  <p>why? how to do it?</p>