Interface Worker


public interface Worker
Handles HTTP requests. Implement this on the class named by the plugin's handlerClass, and the generated scaffold exports a fetch handler that routes to it.

The method looks synchronous and suspends underneath. Binding calls such as env.kv().get(key) return a value rather than a future, because TeaVM rewrites a blocking call into a continuation the host resumes. There is no parallelism on this platform: Cloudflare Workers run in a single thread and the Web Worker API is unavailable, so a Java thread is a fiber on the host's timer queue.

Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    fetch(Request request, Env env, ExecutionCtx ctx)
    Answers one HTTP request.
  • Method Details

    • fetch

      Response fetch(Request request, Env env, ExecutionCtx ctx)
      Answers one HTTP request.
      Parameters:
      request - the incoming request
      env - the bindings declared in the Wrangler configuration
      ctx - the invocation context
      Returns:
      the response to send