mirror of
https://github.com/C9Glax/tranga.git
synced 2025-04-15 12:53:17 +02:00
Add Endpoints to change single requestlimit
This commit is contained in:
parent
0af83f2fd0
commit
ef87e02d0b
@ -79,9 +79,39 @@ public class SettingsController(PgsqlContext context) : Controller
|
|||||||
{
|
{
|
||||||
return StatusCode(501);
|
return StatusCode(501);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates a Request-Limit value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="RequestType">Type of Request</param>
|
||||||
|
/// <param name="requestLimit">New limit in Requests/Minute</param>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">Limit needs to be greater than 0</response>
|
||||||
|
[HttpPatch("RequestLimits/{RequestType}")]
|
||||||
|
[ProducesResponseType(Status200OK)]
|
||||||
|
[ProducesResponseType(Status400BadRequest)]
|
||||||
|
public IActionResult SetRequestLimit(RequestType RequestType, [FromBody]int requestLimit)
|
||||||
|
{
|
||||||
|
if (requestLimit <= 0)
|
||||||
|
return BadRequest();
|
||||||
|
TrangaSettings.UpdateRequestLimit(RequestType, requestLimit);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset all Request-Limits
|
/// Reset Request-Limit
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
[HttpDelete("RequestLimits/{RequestType}")]
|
||||||
|
[ProducesResponseType<string>(Status200OK)]
|
||||||
|
public IActionResult ResetRequestLimits(RequestType RequestType)
|
||||||
|
{
|
||||||
|
TrangaSettings.UpdateRequestLimit(RequestType, TrangaSettings.DefaultRequestLimits[RequestType]);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset Request-Limit
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <response code="200"></response>
|
/// <response code="200"></response>
|
||||||
[HttpDelete("RequestLimits")]
|
[HttpDelete("RequestLimits")]
|
||||||
|
@ -111,7 +111,7 @@ public static class TrangaSettings
|
|||||||
ExportSettings();
|
ExportSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateRateLimit(RequestType requestType, int newLimit)
|
public static void UpdateRequestLimit(RequestType requestType, int newLimit)
|
||||||
{
|
{
|
||||||
requestLimits[requestType] = newLimit;
|
requestLimits[requestType] = newLimit;
|
||||||
ExportSettings();
|
ExportSettings();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user