Skip to content

Add mock response option via TunnelOptions struct for local development #3

@dpkrn

Description

@dpkrn

Add mock response option via TunnelOptions struct for local development

Feature Request

Summary:
Add support for mock responses during local development directly through the TunnelOptions struct.

Details:

  • Introduce a Mock boolean field to TunnelOptions.
  • When Mock is set to true, requests to endpoints should serve mock data instead of forwarding to the backend.
  • Mock data should be configured in a mock.yml file at the project root, allowing per-endpoint mock responses.
  • Users can enable mock support through:
    tunnelOptions := tunnel.TunnelOptions{
        Inspector:    true,
        InspectorAdd: "4040",
        Mock:         true,
    }

Mock file structure should be

mocks:
  - path: /api/user
    response:
      status: 200
      body: { "id": 1, "name": "Mock User" }
  - path: /api/orders
    response:
      status: 200
      body: [ { "orderId": 101, "amount": 10.99 } ]

Acceptance Criteria:

  • Users enable mock data handling via TunnelOptions.
  • The application reads mock responses from mock.yml.
  • Documentation is provided illustrating configuration and usage.

Implementation Suggestions:

  • Implement a loader for mock.yml and mapping from route to response.
  • Middleware should check the Mock field and serve from configuration as appropriate.
  • Provide sample mock.yml and update README.

Benefit: Makes it easier for developers to work independently when APIs or downstream services are not ready or offline.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions