codeblog/ratelimit
Composer 安装命令:
composer require codeblog/ratelimit
包简介
Checks the number of requests made in the header!
README 文档
README
With the diversification of devices and platforms (mobile, wearable, sites, etc.) the data of our applications, business rules and actions are being exposed using HTTP APIs. A very common need in this scenario is to control the use of these APIs, such as the maximum number of requests that a client can perform in a given time range (rate limit). Ratelimit checks the number of requests made in the header.
Com a diversificação de devices e plataformas (mobile, wearable, sites, etc) os dados de nossas aplicações, regras de negocio e ações estão sendo expostos utilizando API’s HTTP. Uma necessidade bastante comum neste cenário é de controle do uso destas APIs, como por exemplo o numero máximo de requests que um cliente pode realizar em um determinado range de tempo (rate limit). O Ratelimit verifica o número de solicitações feitas no cabeçalho.
Highlights
- Limitation of requests to REST API; (Limitação de requests para REST API)
- Keeps security by checking for remaining requests, preventing overuse; (Mantém a segurança com a verificação de requests restantes, impedindo o uso excessivo)
- Valid every request through HTTP requests; (Válida cada solicitação por meio de HTTP requests)
Installation
Ratelimit is available via Composer:
"codeblog/ratelimit": "^1.0"
or run
composer require codeblog/ratelimit
Documentation
HTTP Headers and Response Codes
Use the HTTP headers in order to understand where the application is at for a given rate limit, on the method that was just utilized.
Note that the HTTP headers are contextual. When using app-only auth, they indicate the rate limit for the application context. When using user-based auth, they indicate the rate limit for that user-application context.
- x-rate-limit-limit: maximum limit of requests for the application or method;
- x-rate-limit-remaining: number of requests, remaining requests;
- x-rate-limit-reset: x-rate-limit-reset: remaining time before the rate limit is reset;
Cabeçalhos HTTP e códigos de resposta
Use os cabeçalhos HTTP para entender onde o aplicativo está em um determinado limite de taxa, no método que acabou de ser utilizado.
Observe que os cabeçalhos HTTP são contextuais. Ao usar a autenticação somente de aplicativo, eles indicam o limite de taxa para o contexto do aplicativo. Ao usar a autenticação baseada no usuário, eles indicam o limite de taxa para esse contexto de aplicativo do usuário.
- x-rate-limit-limit: limite maximo de requests para a aplicação ou método;
- x-rate-limit-remaining: o número de pedidos, requests restantes;
- x-rate-limit-reset: tempo restante antes que o limite de taxa seja redefinido;
For details on how to use, see a sample folder in the component directory. In it you will have an example of use for each class. It works like this:
Para mais detalhes sobre como usar, veja uma pasta de exemplo no diretório do componente. Nela terá um exemplo de uso para cada classe. Ele funciona assim:
Usage example
<?php // Initialise your autoloader (this example is using Composer) require 'vendor/autoload.php'; use CodeBlog\RateLimit\RateLimit; $key = 'user-id-999'; $limit = new RateLimit('cache-folder/', $key, 15, 60); var_dump($limit);
Contributing
Please see CONTRIBUTING for details.
Support
Security: If you discover any security related issues, please email whallyssonallain@gmail.com instead of using the issue tracker.
Se você descobrir algum problema relacionado à segurança, envie um e-mail para whallyssonallain@gmail.com em vez de usar o rastreador de problemas.
Thank you
Credits
- Whallysson Avelino (Developer)
- CodBlog (Team)
- All Contributors (This Rock)
License
The MIT License (MIT). Please see License File for more information.
codeblog/ratelimit 适用场景与选型建议
codeblog/ratelimit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「route」 「router」 「routes」 「CodeBlog」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codeblog/ratelimit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codeblog/ratelimit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codeblog/ratelimit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.
Block routes by IP
Provides caching methods which can be easily used for caching routes.
Provide a way to secure accesses to all routes of an symfony application.
Write down your routing mapping at one place
A Laravel-like router for the WordPress Rewrite API
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-17