Class CustomHandlerServer

java.lang.Object
lv.id.jc.dicechess.runtime.CustomHandlerServer

public final class CustomHandlerServer extends Object
A minimal HTTP server for the Azure Functions custom-handler model: one path, one WebhookHandler, no framework.

Azure starts the custom-handler process and tells it which port to listen on via the FUNCTIONS_CUSTOMHANDLER_PORT environment variable; startFromEnvironment(WebhookHandler) reads it. Nothing here is Azure-specific beyond that one variable — the same server runs identically under func start locally, or under any other host that can point HTTP traffic at a port.

  • Method Details

    • startFromEnvironment

      public static HttpServer startFromEnvironment(WebhookHandler handler) throws IOException
      Starts the server on the port named by FUNCTIONS_CUSTOMHANDLER_PORT (default 8080), serving handler at /api/webhook.
      Parameters:
      handler - the webhook logic to serve
      Returns:
      the running server; call HttpServer.stop(int) to shut it down
      Throws:
      IOException - if the port cannot be bound
    • start

      public static HttpServer start(int port, String path, WebhookHandler handler) throws IOException
      Starts the server on an explicit port and path.
      Parameters:
      port - the port to listen on
      path - the path handler answers on
      handler - the webhook logic to serve
      Returns:
      the running server; call HttpServer.stop(int) to shut it down
      Throws:
      IOException - if the port cannot be bound