Skip to content

Commit 6bbf8a1

Browse files
committed
add README
1 parent 22a3016 commit 6bbf8a1

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,87 @@
11
ApiRateLimitBundle
22
==================
3+
4+
[![license](https://img.shields.io/github/license/IndraGunawan/api-rate-limit-bundle.svg?style=flat-square)](https://github.com/IndraGunawan/api-rate-limit-bundle/blob/master/LICENSE.md)
5+
[![Travis](https://img.shields.io/travis/IndraGunawan/api-rate-limit-bundle.svg?style=flat-square)](https://travis-ci.org/IndraGunawan/api-rate-limit-bundle)
6+
[![Scrutinizer Coverage](https://img.shields.io/scrutinizer/coverage/g/IndraGunawan/api-rate-limit-bundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/IndraGunawan/api-rate-limit-bundle/badges/coverage.png?b=master)
7+
[![Scrutinizer](https://img.shields.io/scrutinizer/g/IndraGunawan/api-rate-limit-bundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/IndraGunawan/api-rate-limit-bundle/badges/quality-score.png?b=master)
8+
9+
This bundle provide rate limits protection for [api-platform](https://api-platform.com/) resources.
10+
11+
Installation
12+
------------
13+
14+
### Download the Bundle
15+
16+
Require the bundle with composer.
17+
```bash
18+
composer require indragunawan/api-rate-limit-bundle
19+
```
20+
21+
### Enable the Bundle
22+
23+
Enable the bundle in the kernel:
24+
```php
25+
// app/AppKernel.php
26+
class AppKernel extends Kernel
27+
{
28+
public function registerBundles()
29+
{
30+
$bundles = array(
31+
// ...
32+
new Indragunawan\ApiRateLimitBundle\IndragunawanApiRateLimitBundle(),
33+
);
34+
35+
// ...
36+
}
37+
}
38+
```
39+
40+
Configuration
41+
-------------
42+
43+
### Configuration Reference
44+
45+
Default bundle configuration
46+
```yml
47+
indragunawan_api_rate_limit:
48+
enabled: true
49+
50+
# The service that is used to persist class metadata in a cache. The service has to implement the Doctrine\Common\Cache\Cache interface.
51+
storage: null
52+
53+
# Response header for rate limit information
54+
header:
55+
display: true
56+
names:
57+
limit: X-RateLimit-Limit
58+
remaining: X-RateLimit-Remaining
59+
reset: X-RateLimit-Reset
60+
61+
# Limit the request per period per IP address
62+
throttle:
63+
limit: 60
64+
period: 60
65+
66+
# Exception thrown when rate limit exceeded
67+
exception:
68+
status_code: 429
69+
message: 'API rate limit exceeded for %s.' #%s will be replace with client IP address
70+
custom_exception: null
71+
```
72+
73+
### Disable on development
74+
```yml
75+
indragunawan_api_rate_limit:
76+
enabled: false
77+
```
78+
79+
Todo
80+
----
81+
82+
* Rate limit per user ROLE
83+
84+
License
85+
-------
86+
87+
This bundle is under the MIT license. See the complete [license](LICENSE)

0 commit comments

Comments
 (0)