- 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>
32 lines
878 B
Go
32 lines
878 B
Go
package store
|
|
|
|
import "context"
|
|
|
|
type Endpoint struct {
|
|
ID string `json:"id"`
|
|
URL string `json:"url"`
|
|
CreatedAt string `json:"created_at"`
|
|
UpdatedAt string `json:"updated_at"`
|
|
}
|
|
|
|
type Request struct {
|
|
ID string `json:"id"`
|
|
EndpointID string `json:"endpoint_id"`
|
|
Method string `json:"method"`
|
|
Path string `json:"path"`
|
|
Headers string `json:"headers"`
|
|
Query string `json:"query"`
|
|
Body []byte `json:"body"`
|
|
CreatedAt string `json:"created_at"`
|
|
}
|
|
|
|
type Repository interface {
|
|
CreateEndpoint(ctx context.Context, url string) (*Endpoint, error)
|
|
GetEndpoint(ctx context.Context, id string) (*Endpoint, error)
|
|
AppendRequest(ctx context.Context, endpointID string, req *Request) error
|
|
ListRequests(ctx context.Context, endpointID string, limit int) ([]*Request, error)
|
|
Close() error
|
|
}
|
|
|
|
var _ Repository = (*sqliteRepo)(nil)
|