Get Started!

HTTP Handlers

Creating specialist HTTP Responses via HTTP Handlers.

In some situations you will need the servers response to be some special Content. For example, dynamically generated JSON or compressed files to simple security enforcement for downloading files.

Examples

Registering a Handler

To enable the handlers they must first be registered. When registering a HTTP Handler you must define the URL / Slug that will to route the requests to the corrent handler.

Important Please Read

As NetCanvas compiles the C# & Generates a DLL the definition of the Hadler might change between builds. Therefore the Application must track the registered handlers & un-register them and re-registered the lastest release.

It's relativly easy to achive. Each handler is Registrated with a name and each time the application starts the old handler is unregistered and the new Assemblies' class is re-registered.

Here's the C#

private static void registerHandlers(){

  CanvasApp.RegisterHandlerRoute(
    "NAME-OF-HANDLER",
    "the-url.ext",
    new HandlerType()
  );

}

I normally place this into the C# App.cs which generated automatically if you've created a DataType. The registerHandlers method is executed in the init of the static class.

The Global static Application is a good spot as you can be sure it's been referenced and therefore, it's init method executed.