WebServerDispatcher


@UnstableApi
class WebServerDispatcher : 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

const String!
NOT_FOUND_BODY = "Resource not found!"

The body associated with a response for an unrecognized path.

Public functions

MockResponse!
java-static WebServerDispatcher!

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

java-static String!

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

Constants

NOT_FOUND_BODY

const val NOT_FOUND_BODY = "Resource not found!": String!

The body associated with a response for an unrecognized path.

Public functions

dispatch

fun dispatch(request: RecordedRequest!): MockResponse!

forResources

java-static fun forResources(
    resources: (Mutable)Iterable<WebServerDispatcher.Resource!>!
): WebServerDispatcher!

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

getRequestPath

java-static fun getRequestPath(request: RecordedRequest!): String!

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