Skip to content

Commit

Permalink
any
Browse files Browse the repository at this point in the history
  • Loading branch information
code-lime committed Dec 27, 2023
1 parent f96f467 commit 12fdde1
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions src/WebGP/Controllers/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private static void WebhookCacheWithTick()
}
}

[HttpPost("cache/webhook/send")]
[HttpPost("cache/webhook")]
public async Task<string> PostWebhookCache(
[FromQuery(Name = "id")] string id,
CancellationToken cancellationToken)
Expand All @@ -38,8 +38,40 @@ public async Task<string> PostWebhookCache(
return e.ToString();
}
}
[HttpGet("cache/webhook")]
public string GetWebhookCache(
[FromQuery(Name = "id")] string id)
{
try
{
WebhookCacheWithTick();
return webhookCache.TryRemove(id, out var value) ? value.Data.ToJsonString() : "null";
}
catch (Exception e)
{
return e.ToString();
}
}


[HttpPost("cache/webhook/send")]
public async Task<string> PostWebhookCacheSend(
[FromQuery(Name = "id")] string id,
CancellationToken cancellationToken)
{
try
{
WebhookCacheWithTick();
webhookCache[id] = new TimeoutJson((await JsonSerializer.DeserializeAsync<JsonObject>(Request.Body, cancellationToken: cancellationToken))!, DateTime.Now.AddMinutes(1));
return "ok";
}
catch (Exception e)
{
return e.ToString();
}
}
[HttpGet("cache/webhook/raw")]
public async Task<string> RawWebhookCache(
public async Task<string> GetWebhookCacheRaw(
[FromQuery(Name = "id")] string id,
CancellationToken cancellationToken)
{
Expand All @@ -56,7 +88,7 @@ public async Task<string> RawWebhookCache(
}

[HttpGet("cache/webhook/get")]
public string GetWebhookCache(
public string GetWebhookCacheGet(
[FromQuery(Name = "id")] string id)
{
try
Expand Down

0 comments on commit 12fdde1

Please sign in to comment.