Class MockHandler

java.lang.Object
io.karatelabs.core.MockHandler
All Implemented Interfaces:
Function<HttpRequest,HttpResponse>

public class MockHandler extends Object implements Function<HttpRequest,HttpResponse>
Mock server request handler that routes requests to matching scenarios. Implements Function<HttpRequest, HttpResponse> for use with HttpServer. Uses ScenarioRuntime and StepExecutor for proper step execution, ensuring all keywords (def, xml, json, call, etc.) work correctly.
  • Field Details

    • KARATE_MOCK_HEADER

      public static final String KARATE_MOCK_HEADER
      The disclosure header every karate-fabricated mock response carries: Karate-Mock: true. It exists so a consumer can distinguish a stand-in from the real system as a fact reported by the responder, not as an inference from its address — a real service on localhost is ordinary, so nothing about a URL can carry this. Read it that way in both directions: its presence is certain, its absence proves nothing (any non-karate stub answers exactly like a real server). Suppressible via MockConfig#setMockHeaderEnabled(false).
      See Also:
  • Constructor Details

  • Method Details