定制 oussema-khlifi/api-rate-limiter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

oussema-khlifi/api-rate-limiter

Composer 安装命令:

composer require oussema-khlifi/api-rate-limiter

包简介

API RATE LIMITER is a package that provides a middelware for laravel applications to enforce rate limiting on incoming API requests using the Token Bucket Algorithm, it helps to prevent abuse of API resources and ensures fair access to the API for all users

README 文档

README

The API Rate Limiter package provides a middleware for Laravel applications to implement rate limiting on incoming API requests using the Token Bucket Algorithm. Rate limiting helps prevent abuse of API resources and ensures fair access to the API for all users.

Features

  • Token Bucket Algorithm: Efficiently controls the rate of incoming API requests per user.
  • Customizable Rate Limits: Set tokens generated per minute and maximum tokens allowed per user.
  • Middleware Integration: Apply rate limiting to specific API routes or globally using the middleware.
  • Lightweight and Easy to Use: Simple integration with Laravel applications.

Installation

Install the package via Composer:

composer require oussema-khlifi/api-rate-limiter

Usage

Import the ApiRateLimiterMiddleware in your App\Http\Kernel.php file. Apply the middleware to specific API routes or globally in the middleware stack.

use OussemaKhlifi\ApiRateLimiter\Middleware\ApiRateLimiterMiddleware;

protected $middlewareGroups = [
    'api' => [
        // Other middleware...
        ApiRateLimiterMiddleware::class,
    ],
];

Configuration

The default rate limiting settings can be modified in the config/api_rate_limiter.php configuration file:

return [
    'tokens_per_minute' => 60,
    'max_tokens' => 60,
];

License

This package is open-source software licensed under the MIT License.

Support

If you encounter any issues or have questions, please open an issue.

Contribution

Contributions are welcome! If you wish to contribute, please fork the repository, create a new branch, and submit a pull request.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-22