add additional overloads for script plugin web request helper
This commit is contained in:
parent
e8ab56cd9b
commit
520a76a15e
@ -28,14 +28,27 @@ public class ScriptPluginHelper
|
|||||||
RequestUrl(new ScriptPluginWebRequest(url), callback);
|
RequestUrl(new ScriptPluginWebRequest(url), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GetUrl(string url, string bearerToken, Delegate callback)
|
||||||
|
{
|
||||||
|
var headers = new Dictionary<string, string> { { "Authorization", $"Bearer {bearerToken}" } };
|
||||||
|
RequestUrl(new ScriptPluginWebRequest(url, Headers: headers), callback);
|
||||||
|
}
|
||||||
|
|
||||||
public void GetUrl(string url, Dictionary<string, string> headers, Delegate callback)
|
public void GetUrl(string url, Dictionary<string, string> headers, Delegate callback)
|
||||||
{
|
{
|
||||||
RequestUrl(new ScriptPluginWebRequest(url, Headers: headers), callback);
|
RequestUrl(new ScriptPluginWebRequest(url, Headers: headers), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostUrl(string url, Dictionary<string, string> headers, Delegate callback)
|
public void PostUrl(string url, string body, string bearerToken, Delegate callback)
|
||||||
{
|
{
|
||||||
RequestUrl(new ScriptPluginWebRequest(url, null, "POST", Headers: headers), callback);
|
var headers = new Dictionary<string, string> { { "Authorization", $"Bearer {bearerToken}" } };
|
||||||
|
RequestUrl(
|
||||||
|
new ScriptPluginWebRequest(url, body, "POST", Headers: headers), callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PostUrl(string url, string body, Dictionary<string, string> headers, Delegate callback)
|
||||||
|
{
|
||||||
|
RequestUrl(new ScriptPluginWebRequest(url, body, "POST", Headers: headers), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestUrl(ScriptPluginWebRequest request, Delegate callback)
|
public void RequestUrl(ScriptPluginWebRequest request, Delegate callback)
|
||||||
@ -77,7 +90,6 @@ public class ScriptPluginHelper
|
|||||||
{
|
{
|
||||||
var entered = false;
|
var entered = false;
|
||||||
using var tokenSource = new CancellationTokenSource(RequestTimeout);
|
using var tokenSource = new CancellationTokenSource(RequestTimeout);
|
||||||
|
|
||||||
using var client = new HttpClient();
|
using var client = new HttpClient();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -278,7 +278,7 @@ public class ScriptPluginV2 : IPluginV2
|
|||||||
typeof(ScriptPluginExtensions), typeof(LoggerExtensions))
|
typeof(ScriptPluginExtensions), typeof(LoggerExtensions))
|
||||||
.AllowClr(typeof(System.Net.Http.HttpClient).Assembly, typeof(EFClient).Assembly,
|
.AllowClr(typeof(System.Net.Http.HttpClient).Assembly, typeof(EFClient).Assembly,
|
||||||
typeof(Utilities).Assembly, typeof(Encoding).Assembly, typeof(CancellationTokenSource).Assembly,
|
typeof(Utilities).Assembly, typeof(Encoding).Assembly, typeof(CancellationTokenSource).Assembly,
|
||||||
typeof(Data.Models.Client.EFClient).Assembly, typeof(IW4MAdmin.Plugins.Stats.Plugin).Assembly)
|
typeof(Data.Models.Client.EFClient).Assembly, typeof(IW4MAdmin.Plugins.Stats.Plugin).Assembly, typeof(ScriptPluginWebRequest).Assembly)
|
||||||
.CatchClrExceptions()
|
.CatchClrExceptions()
|
||||||
.AddObjectConverter(new EnumsToStringConverter()));
|
.AddObjectConverter(new EnumsToStringConverter()));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user