WebServerDispatcher


@UnstableApi
public class WebServerDispatcher extends Dispatcher


A Dispatcher for okhttp3.mockwebserver.MockWebServer that allows per-path customisation of the static data served.

Summary

Nested types

A resource served by WebServerDispatcher.

Builder for Resource.

Constants

static final String
NOT_FOUND_BODY = "Resource not found!"

The body associated with a response for an unrecognized path.

Public methods

MockResponse
static WebServerDispatcher

Constructs a dispatcher that handles requests based the provided Resource instances.

static String

Returns the path for a given RecordedRequest, stripping any query parameters.

Constants

NOT_FOUND_BODY

public static final String NOT_FOUND_BODY = "Resource not found!"

The body associated with a response for an unrecognized path.

Public methods

dispatch

public MockResponse dispatch(RecordedRequest request)

forResources

public static WebServerDispatcher forResources(Iterable<WebServerDispatcher.Resource> resources)

Constructs a dispatcher that handles requests based the provided Resource instances.

getRequestPath

public static String getRequestPath(RecordedRequest request)

Returns the path for a given RecordedRequest, stripping any query parameters.