Added first pass at custom static router mod

This commit is contained in:
Chomp
2025-02-08 12:58:56 +00:00
parent c9c1af653b
commit 00d05445d6
2 changed files with 59 additions and 0 deletions
@@ -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"
}