Interface WebserverHandler

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface WebserverHandler
A handler/callback for incoming HTTP requests targeting a webserver route which was registered via Plugin.registerWebserverHandler(String, WebserverHandler). The onRequest(HttpRequestEvent) method is called whenever a request targeting the particular route is received, allowing you to read the request and provide a response.

Since this is a functional interface, it can be implemented using a lambda expression.

Note: The onRequest(HttpRequestEvent) method is invoked on a webserver worker thread, NOT on the main thread. If you need to access game state, use Plugin.enqueue(Runnable) to defer the access to the main thread.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called when an HTTP request targeting the registered route is received.
  • Method Details

    • onRequest

      void onRequest(HttpRequestEvent event)
      Called when an HTTP request targeting the registered route is received.
      Parameters:
      event - the incoming request event (used to read the request and set the response).