roji can return mock responses without a real backend, which is useful for frontend development when the API isn’t ready yet.

How It Works

Define mock responses using Docker labels on any container. The container doesn’t need to run a web server — it just needs to be connected to the roji network.

Label Syntax

LabelDescription
roji.mock.{METHOD}.{PATH}Response body (JSON string)
roji.mock.status.{METHOD}.{PATH}HTTP status code (default: 200)

Example: Mock API

services:
  mock-api:
    image: alpine
    command: ["sleep", "infinity"]
    labels:
      - "roji.host=api.dev.localhost"
      - 'roji.mock.GET./api/users=[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]'
      - 'roji.mock.GET./api/health={"status":"ok"}'
      - "roji.mock.status.POST./api/users=201"
    networks:
      - roji

networks:
  roji:
    external: true

This creates:

  • GET https://api.dev.localhost/api/users200 with user list JSON
  • GET https://api.dev.localhost/api/health200 with health status
  • POST https://api.dev.localhost/api/users201 (empty body)

Use Cases

  • Frontend development — Work on the UI while the backend team builds the real API
  • API prototyping — Quickly define endpoints to test integrations
  • Error testing — Mock error responses (4xx, 5xx) to test error handling
labels:
  - "roji.mock.GET./api/error={\"error\":\"Internal Server Error\"}"
  - "roji.mock.status.GET./api/error=500"