dingo / dingo/api

How to use custom throttles defined in api.php

Open
#1,353 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
9.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

I have a custom throttle defined in api.php:
```
'throttling' => [

'mythrottle' => new MyPath\MyThrottle(
[
'limit' => 5,
'expires' => 1440
])
],
```

How and where can I apply "mythrottle" to my routes?

I tried this:
```
$api->group(['middleware' => 'api.throttle', 'prefix'=>'mobile',
'throttle'=>'mythrottle'], function ($api) {
// Do something

});
```
I get this error: "Class mythrottle does not exist in vendor/laravel/framework/src/Illuminate/Container/Container.php, line: 734"

Of course, passing the actual class 'throttle'=>'MyPath\MyThrottle' works, but I guess the definition in api.php throttling array is meant for something.

Also, the match method is never called. What do I need to do so the match method in my custom throttle is invoked and so add custom matching logic?

What am I missing? Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.