- What? Fake responses from remote services.
- Why? I wanted it.
- How? Go, Bubbletea, fsnotify, Gin
NOTICE: This is a development aid and not intended to be used to run production workloads.
cd examples/ && fake-ops
Flags:
--services
Directory of service files. See examples/services.- default:
./services
- default:
--results
Directory of http result files. See examples/results.- default:
./results
- default:
go install .
OR
go install github.com/crit/fake-ops
name: products # Must match a folder containing response files.
type: http # Indicates this is an HTTP server service.
port: 3002 # Port to run the HTTP server on.
skip: true # If true, skips running the service but lists it.
Example uses the temporal cli published by Temporal.io
name: temporal # Name of the service.
type: app # Indicates this is an Application service.
port: 7233 # Port that the application will run on for communication.
stdout: false # If true, stdout will be piped to fake-ops.
stderr: false # If true, stderr will be piped to fake-ops.
skip: false # If true, skips running the service but lists it.
exec: temporal server start-dev --port {port} # Command to run this application. {port} will be substituted at runtime.
# GET /users/:id 200 application/json
{
"status": "SUCCESS",
"message": "User found.",
"data": {
"user": {
"id": "1",
"name": "Alice Johnson",
"email": "alice.johnson@example.com",
"role": "admin"
}
}
}
First line contains the data needed to serve this file's contents. Space delimited.
- Must start with
#
- HTTP Method
- Route including any path parameters.
- HTTP Status Code
- Content-Type of the response.
All content after the first line is used as the response body.
NOTE: yaml in this case is used for syntax highlighting of JSON responses. You can choose any file format that suites your needs. See examples/results/static for more variety.
fake-ops
monitors all response files and their parent directory for changes. It will reload the HTTP service when
one of the files is changed or a new one created.