Package io.karatelabs.core
Class MockHandler
java.lang.Object
io.karatelabs.core.MockHandler
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe disclosure header every karate-fabricated mock response carries:Karate-Mock: true. -
Constructor Summary
ConstructorsConstructorDescriptionMockHandler(Feature feature) MockHandler(Feature feature, Map<String, Object> args) MockHandler(String featurePath) MockHandler(List<Feature> features, Map<String, Object> args, String pathPrefix, boolean javaBridgeEnabled, boolean requestExpressionsEnabled) -
Method Summary
-
Field Details
-
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 onlocalhostis 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 viaMockConfig#setMockHeaderEnabled(false).- See Also:
-
-
Constructor Details
-
MockHandler
-
MockHandler
-
MockHandler
-
MockHandler
-
MockHandler
-
-
Method Details
-
getCurrentRequest
-
apply
- Specified by:
applyin interfaceFunction<HttpRequest,HttpResponse>
-
getConfig
-
getGlobals
-
getVariable
-