- Add mock_status, mock_headers, mock_body columns to endpoints schema
- Add MockConfig struct and UpsertMock to Repository interface
- Implement UpsertMock in sqliteRepo (INSERT ON CONFLICT UPDATE)
- Update GetEndpoint to return mock configuration when present
- Add PUT /e/{endpoint_id}/mock handler with JSON body {status, headers, body}
- Add catch-all /{endpoint_id} handler returning mock or default 200
- Header sanitization: only allow Content-Type, Cache-Control, X-*
- Wire handler into cmd/hatch main with SQLite store
- Fix Dockerfile: COPY go.sum for reproducible builds
- Tests: store mock CRUD, handler mock config + header sanitization
Co-Authored-By: Paperclip <noreply@paperclip.ing>
19 lines
674 B
SQL
19 lines
674 B
SQL
CREATE TABLE IF NOT EXISTS endpoints (
|
|
id TEXT NOT NULL PRIMARY KEY,
|
|
url TEXT NOT NULL UNIQUE,
|
|
created_at TEXT NOT NULL,
|
|
updated_at TEXT NOT NULL
|
|
);
|
|
CREATE TABLE IF NOT EXISTS requests (
|
|
id TEXT NOT NULL PRIMARY KEY,
|
|
endpoint_id TEXT NOT NULL REFERENCES endpoints(id),
|
|
method TEXT NOT NULL,
|
|
path TEXT NOT NULL,
|
|
headers TEXT NOT NULL DEFAULT '{}',
|
|
query TEXT NOT NULL DEFAULT '',
|
|
body BLOB,
|
|
created_at TEXT NOT NULL
|
|
);
|
|
CREATE INDEX IF NOT EXISTS idx_requests_endpoint_id ON requests(endpoint_id);
|
|
CREATE INDEX IF NOT EXISTS idx_requests_created_at ON requests(created_at);
|