Added first pass at custom static router mod
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using Core.DI;
|
||||
using Core.Models.Utils;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace ExampleMods.Mods._10CustomRoute;
|
||||
|
||||
// Flag our mod as a type of static router
|
||||
[Injectable(InjectableTypeOverride = typeof(StaticRouter))]
|
||||
public class CustomStaticRouter : StaticRouter
|
||||
{
|
||||
public CustomStaticRouter(
|
||||
JsonUtil jsonUtil) : base(
|
||||
jsonUtil,
|
||||
// Add an array of routes we want to add
|
||||
GetCustomRoutes()
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
private static List<RouteAction> GetCustomRoutes()
|
||||
{
|
||||
return
|
||||
[
|
||||
new RouteAction(
|
||||
"/example/route/static",
|
||||
(
|
||||
url,
|
||||
info,
|
||||
sessionId,
|
||||
output
|
||||
) => HandleRoute(url, info as ExampleStaticRequestData, sessionId)
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
private static string HandleRoute(string url, ExampleStaticRequestData info, string sessionId)
|
||||
{
|
||||
// Stuff goes here
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
public class ExampleStaticRequestData : IRequestData
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"Name": "10CustomStaticRouter",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"IncompatibileMods": [],
|
||||
"Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"IsBundleMod": false,
|
||||
"Author": "SPT",
|
||||
"Contributors": [],
|
||||
"Licence": "MIT"
|
||||
}
|
||||
Reference in New Issue
Block a user