mardi 25 octobre 2016

Laravel 5.3 rate limit to return a JSON payload

I'm building an API on top of Laravel. I'd like to use the built in rate limiting capabilities by using the Throttle middleware.

Problem is, when the throttle middleware triggers the response is:

// Response headers
Too Many Attempts.

My API uses an error payload in JSON that looks like the following:

// Response headers
{
  "status": "error",
  "error": {
    "code": 404,
    "message": "Resource not found."
  }
}

What is the best way to get the Throttle middleware to return an output in the manner I require?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire