Very easy to use a current limiting component, the code is very simple, based on the webman framework.

Overview

webman-throttler

限流类(Throttler)提供了一种非常简单的方法,可以将用户要执行的活动限制为在设定的时间段内只能进行一定次数的尝试。这最常用于对 API 进行速率限制,或限制用户针对表单进行的尝试次数,以帮助防止暴力攻击。 该类可用于你根据设置的时间来进行限制的操作。

限流类

  • 全局中间件,整个应用接口限流,
  • 路由中间件,某些功能接口请求速率限制

缓存依据的是Support\Cache的 instance(), 其他类只要是实现 get($key, $default = null), set($key, $value, $ttl = null), delete($key) funtion就行.

项目地址:https://github.com/nsp-team/webman-throttler

安装

composer require nsp-team/webman-throttler

基本用法

默认 开启全局中间件限流

return [
    '' => [
        \NspTeam\WebmanThrottler\Middleware\ThrottlerMiddleware::class,
    ]
];

你也可以启用路由中间件,控制接口请求速率限制 例如:

Route::group('/sys/user', static function () {
    Route::post('/test', [User::class, 'test']);
})->middleware([
    \NspTeam\WebmanThrottler\Middleware\ThrottlerMiddleware::class
]);
You might also like...
A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently

A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently

Debug - The Debug component provides tools to ease debugging PHP code.

Debug Component CAUTION: this component is deprecated since Symfony 4.4. Instead, use the ErrorHandler component. The Debug component provides tools t

The ErrorHandler component provides tools to manage errors and ease debugging PHP code

ErrorHandler Component The ErrorHandler component provides tools to manage errors and ease debugging PHP code. Getting Started $ composer require symf

The VarExporter component allows exporting any serializable PHP data structure to plain PHP code.

The VarExporter component allows exporting any serializable PHP data structure to plain PHP code. While doing so, it preserves all the semantics associated with the serialization mechanism of PHP (__wakeup, __sleep, Serializable).

This project is very diverse and based upon many languages and libraries such as C++, Python, JavaScript, PHP and MQTT

ADMS-Real-time-project This project is very diverse and based upon many languages and libraries such as C++, Python, JavaScript, PHP and MQTT Advance_

This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized objects in DynamoDB 🚀.

DynamoDB Storable This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized

Echo your public IP address with a very simple cURL request

Echo your public IP address with a very simple cURL request

A very simple way to handle self-hosted WordPress plugin updates

Simple WP Plugin Update handling A very simple way to handle self-hosted WordPress plugin updates This uses the "update_plugins_{$hostname}" filter in

Comments
  • 如果可以自定义response

    如果可以自定义response

    首先谢谢大佬的插件,使用起来很方便 唯一不足的地方就是 response是写死的 { "success": false, "msg": "请求此时太频繁" } 因为我们的输出有标准的统一 所以 如果支持自定义response 就更完美了 谢谢

    opened by evilk123 2
Releases(v1.0.1)
Owner
nsp-team
nsp-team
Webman quickly creates a verification code tool similar to Google verification code

webman-captcha-grid webman quickly creates a verification code tool similar to Google verification code webman 快速创建一个类似于 Google 点图验证码的本地验证码扩展 介绍 webma

听风吹雨 6 Dec 5, 2022
A lightweight queue based on Redis Stream for webman plugin.

workbunny/webman-rqueue ?? A lightweight queue based on Redis Stream for webman plugin. ?? A lightweight queue based on Redis Stream for webman plugin

workbunny 10 Dec 12, 2022
Currency is a simple PHP library for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangerate.host

Currency Currency is a simple PHP library for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangera

Amr Shawky 19 Dec 12, 2022
A PHP implementation of RabbitMQ Client for webman plugin.

workbunny/webman-rabbitmq ?? A PHP implementation of RabbitMQ Client for webman plugin. ?? A PHP implementation of RabbitMQ Client for webman plugin 常

workbunny 15 Dec 15, 2022
Laravel illuminate/filesystem for webman

webman-tech/laravel-filesystem Laravel illuminate/filesystem for webman 介绍 站在巨人(laravel)的肩膀上使文件存储使用更加可靠和便捷 所有方法和配置与 laravel 几乎一模一样,因此使用方式完全参考 Laravel文

null 5 Dec 15, 2022
Description: A simple plugin that sets the current admin page to always be at the top of the admin menu.

=== Sticky Admin Menu === Contributors: sc0ttkclark Donate link: https://www.scottkclark.com/ Tags: admin menu, sticky Requires at least: 4.4 Tested u

Scott Kingsley Clark 2 Sep 29, 2022
The Current US Version of PHP-Nuke Evolution Xtreme v3.0.1b-beta often known as Nuke-Evolution Xtreme. This is a hardened version of PHP-Nuke and is secure and safe. We are currently porting Xtreme over to PHP 8.0.3

2021 Nightly Builds Repository PHP-Nuke Evolution Xtreme Developers TheGhost - Ernest Allen Buffington (Lead Developer) SeaBeast08 - Sebastian Scott B

Ernest Buffington 7 Aug 28, 2022
Shows you the current diocese that you're in, as well as the bishop.

Use config.php to create variables $dbuser and $dbpass for the database connection. Run `php -f ./coa/newcheck.php` to update database information fr

Canon Law Ninjas 2 Dec 2, 2021
Yab copy to new - A Textpattern plugin. Copies the current article content to a new one.

yab_copy_to_new Displays a new button in article write tab to copy the current article to a new one. Version: 0.2 Table of contents Plugin requirement

Tommy Schmucker 2 Dec 15, 2017
X1 - A very simple web based note solution that's designed to serve as my second brain.

X1 A very simple web based note solution that's designed to serve as my second brain. Starting Server To start the tool simply clone the repo and then

Joel Dare 118 Dec 28, 2022