{"id":31946907,"url":"https://github.com/sachin-duhan/gomock","last_synced_at":"2026-07-01T16:32:09.450Z","repository":{"id":243296541,"uuid":"809669350","full_name":"sachin-duhan/gomock","owner":"sachin-duhan","description":"Making stub server easy, all you need is sample JSON response that needs mockup","archived":false,"fork":false,"pushed_at":"2025-04-12T23:03:46.000Z","size":475,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-14T11:26:08.701Z","etag":null,"topics":["golang","mock-server","server"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sachin-duhan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-06-03T08:13:37.000Z","updated_at":"2025-04-12T23:03:50.000Z","dependencies_parsed_at":"2025-04-15T08:31:54.701Z","dependency_job_id":null,"html_url":"https://github.com/sachin-duhan/gomock","commit_stats":null,"previous_names":["sachin-duhan/mock-server","sachin-duhan/gomock"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sachin-duhan/gomock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachin-duhan%2Fgomock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachin-duhan%2Fgomock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachin-duhan%2Fgomock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachin-duhan%2Fgomock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sachin-duhan","download_url":"https://codeload.github.com/sachin-duhan/gomock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachin-duhan%2Fgomock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35015053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","mock-server","server"],"created_at":"2025-10-14T11:24:01.790Z","updated_at":"2026-07-01T16:32:09.445Z","avatar_url":"https://github.com/sachin-duhan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gomock - Simple HTTP Mock Server\n\nA lightweight mock server that lets you quickly set up HTTP endpoints with configurable responses. Perfect for development and testing when you need to simulate API responses.\n\n## Use Case\n- **API Mocking**: This mock server can be used to simulate API responses for testing and development purposes.\n- **Response Simulation**: The server reads predefined responses from JSON files, making it easy to simulate different API scenarios for various endpoints.\n- **Environment-specific Configuration**: The folder path for the JSON files can be defined through an environment variable, allowing for flexible configuration across different environments.\n\n## Setup\n```bash\ngit clone github.com/sachin-duhan/gomock\ncd gomock\ngo mod tidy\nmake test\nmake run\n```\n\n## Quick Start\n1. Build:\n```bash\ndocker build -t gomock .\n```\n\n2. Run:\n```bash\n# Using default settings\ndocker run -p 8080:8080 gomock\n\n# With custom JSON folder\ndocker run -p 8080:8080 -v $(pwd)/yours-endpoints:/app/endpoints gomock\n```\n## Features\n\n- **Simple JSON Configuration**: Define endpoints and their responses in JSON files\n- **Multiple Responses**: Support different responses based on input body or status code\n- **Status Code Override**: Use `x-stub-resStatus` header to force specific status codes\n- **Endpoints Discovery**: Built-in `/endpoints` route lists all available endpoints\n- **Custom Endpoint Paths**: Define explicit API paths in your JSON files\n\n## JSON File Structure\n\nEach JSON file in your endpoints folder represents one endpoint. There are two ways to define the endpoint path:\n\n1. **Default**: The filename becomes the endpoint path (e.g., `users.json` → `/users`)\n2. **Custom**: Use the `path` property to explicitly define the endpoint path (e.g., `\"path\": \"/api/v1/users\"`)\n\nThe `path` property is especially useful for complex API paths with multiple segments.\n\n### Basic Example (GET endpoint)\n```json\n{\n  \"method\": \"GET\",\n  \"responses\": [\n    {\n      \"status\": 200,\n      \"body\": {\"message\": \"Success\"}\n    }\n  ]\n}\n```\n\n### Example with Custom Path\n```json\n{\n  \"method\": \"POST\",\n  \"path\": \"/api/v1/auth/token\",\n  \"responses\": [\n    {\n      \"status\": 200,\n      \"body\": {\"token\": \"eyJ0eXAi...\"}\n    }\n  ]\n}\n```\n\n### Input Body Matching (POST endpoint)\n```json\n{\n  \"method\": \"POST\",\n  \"responses\": [\n    {\n      \"status\": 201,\n      \"input_body\": {\n        \"name\": \"John\",\n        \"email\": \"john@example.com\"\n      },\n      \"body\": {\n        \"id\": 1,\n        \"message\": \"User created\"\n      }\n    },\n    {\n      \"status\": 400,\n      \"input_body\": {\n        \"name\": \"John\"\n      },\n      \"body\": {\n        \"error\": \"Email is required\"\n      }\n    }\n  ]\n}\n```\n\n## Using the x-stub-resStatus Header\n\nYou can force a specific status code response by using the `x-stub-resStatus` header:\n\n```bash\n# Force a 401 response for the /users endpoint\ncurl -H \"x-stub-resStatus: 401\" http://localhost:8080/users\n```\n\nIf the requested status code exists in the endpoint's responses, that response will be used. If not, it will fall back to the default response selection logic.\n\n## Development\n\n1. Clone the repo\n2. Install dependencies: `go mod download`\n3. Run tests: `go test ./...`\n4. Start server: `go run main.go`\n\n### List Available Endpoints\n```bash\ncurl http://localhost:8080/endpoints\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsachin-duhan%2Fgomock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsachin-duhan%2Fgomock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsachin-duhan%2Fgomock/lists"}