Skip to content

Additional Configuration

Most Mockzilla configuration is relatively self-explanatory and documented here.

Logging

By default, Mockzilla outputs minimal logging. If more is needed to help with debugging, enable it as follows.

val config = MockzillaConfig.Builder()
    .setLogLevel(MockzillaConfig.LogLevel.Verbose)
    ...
    .build()
let config = MockzillaConfigBuilder()
    .setLogLevel(level: LogLevel.verbose)
    ...
    .build()

Release Mode

Warning

We still don't recommend releasing to non-developers, even with this mode if at all avoidable. Mockzilla is NOT a production server substitute and should NOT be used in production.

By default, the Mockzilla server can be called by anyone on the network via the device's IP address. This is often useful for debugging.

If you need to release your mock app to non-developers, we recommend enabling "release mode" which does the following.

  1. Introduces rate limiting to the server
  2. Enforces rudamentary token authentication on each request (explained below).
  3. Only allows connections from 127.0.0.1 (i.e from apps running on the device).
val config = MockzillaConfig.Builder()
    .setIsReleaseModeEnabled(true)

    // Following is optional, the defaults should be fine for most apps
    .setReleaseModeConfig(
            MockzillaConfig.ReleaseModeConfig(
                rateLimit = 60,
                rateLimitRefillPeriod = 60.seconds,
                tokenLifeSpan = 0.5.seconds
            )
        )
let config = MockzillaConfigBuilder()
    .setIsReleaseModeEnabled(isRelease: true)
     // Following is optional, the defaults should be fine for most apps
    .setReleaseModeConfig(
        releaseConfig: MockzillaConfig.ReleaseModeConfig(
            rateLimit: 60,
            rateLimitRefillPeriod: 60_000, // milliseconds
            tokenLifeSpan: 500 // milliseconds
        )
    )

An additional header now needs to be added to each request. The header changes per request and is generated as follows.

val params = startMockzilla(config, ..)

// Generate a new header for each request.
val header = params.authHeaderProvider.generateHeader()
let params = startMockzilla(config: config, ..)

// Generate a new header for each request.
let header = params.authHeaderProvider.generateHeader()
Back to top