Building WebTSM Services Extensions
Introduction
On this page you find a short description how to implement your own custom WebTSM Services extension.
How to Build a New WebTSM Services Extension
- Create a new Class Library Project in Visual Studio and select .NET 5.0 as Target Framework
- Add NuGet Package "HAKOM.Framework.Services"
- Add HAKOM.Config and HAKOM.License to the Project and set the following FileProperties for each file:
Edit Project Properties → Build Events
POWERSHELLxcopy "$(TargetDir)$(TargetName).dll" "$(TargetDir)extensions\" /y xcopy "$(TargetDir)$(TargetName).pdb" "$(TargetDir)extensions\" /y del "$(TargetDir)$(TargetName).dll" del "$(TargetDir)$(TargetName).pdb"
Edit your csproj file and add the following target
XML<Target Name="DotNetPublish" AfterTargets="PostBuild"> <Exec Command="dotnet publish --no-build -f net5.0 -o "$(TargetDir)"" /> </Target>
- Edit Project Properties → Debug
Create your WebTSM Services Extension Controller Class:
Minimal Working Extension
C#using System; using HAKOM.Framework.Services.Extensibility; using Microsoft.AspNetCore.Mvc; namespace MyWebTSMExtension { [WebTSMServiceExtension(Name: "mwe")] public class MWExtensionController : ExtensionBaseController { [Route("foo")] public IActionResult DoSomething([FromQuery]string param1) { return Ok("whatever"); } } }
- Start Debugging and call your new Extension Method via GET "{ServiceURL}/extensions/mwe/foo"
Note that when prefixing the Name
property of the WebTSMServiceExtension
with anything that ends in a /
you can expose several controllers under a common extension name.
Example:
Minimal Working Extension
using System;
using HAKOM.Framework.Services.Extensibility;
using Microsoft.AspNetCore.Mvc;
namespace MyWebTSMExtension
{
[WebTSMServiceExtension(Name: "mwe/onepart")]
public class MWExtensionController : ExtensionBaseController
{
[Route("foo")]//This endpoint will be exposed under /extensions/mwe/onepart/foo
public IActionResult DoSomething([FromQuery]string param1)
{
return Ok("whatever");
}
}
[WebTSMServiceExtension(Name: "mwe/otherpart")]
public class MWExtensionController : ExtensionBaseController
{
[Route("foo")]//This endpoint will be exposed under /extensions/mwe/otherpart/foo
public IActionResult DoSomething([FromQuery]string param1)
{
return Ok("whatever");
}
}
}