diff --git a/ExampleMods/Mods/10CustomRoute/CustomStaticRouter.cs b/ExampleMods/Mods/10CustomRoute/CustomStaticRouter.cs new file mode 100644 index 00000000..f0fdafb7 --- /dev/null +++ b/ExampleMods/Mods/10CustomRoute/CustomStaticRouter.cs @@ -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 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 +{ +} diff --git a/ExampleMods/Mods/10CustomRoute/package.json b/ExampleMods/Mods/10CustomRoute/package.json new file mode 100644 index 00000000..caaf9248 --- /dev/null +++ b/ExampleMods/Mods/10CustomRoute/package.json @@ -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" +}