{"id":43814613,"url":"https://github.com/kpiljoong/dserver","last_synced_at":"2026-02-06T00:13:10.262Z","repository":{"id":267276110,"uuid":"900747784","full_name":"kpiljoong/dserver","owner":"kpiljoong","description":"Dynamic Mock Server for RESTful APIs with Hot Reloading and Customizable Responses","archived":false,"fork":false,"pushed_at":"2024-12-22T10:46:40.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-22T11:33:27.947Z","etag":null,"topics":["api-mocking","api-testing","dynamic-mocking","golang","hot-reloading","mock-api","mock-server","rest-mock-server"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kpiljoong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-12-09T11:57:43.000Z","updated_at":"2024-12-22T10:49:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"3b12d7a0-4dc5-4e05-880c-c16c18d65dfd","html_url":"https://github.com/kpiljoong/dserver","commit_stats":null,"previous_names":["kpiljoong/dserver"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kpiljoong/dserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpiljoong%2Fdserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpiljoong%2Fdserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpiljoong%2Fdserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpiljoong%2Fdserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kpiljoong","download_url":"https://codeload.github.com/kpiljoong/dserver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpiljoong%2Fdserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29140053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T23:14:48.546Z","status":"ssl_error","status_checked_at":"2026-02-05T23:14:35.724Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api-mocking","api-testing","dynamic-mocking","golang","hot-reloading","mock-api","mock-server","rest-mock-server"],"created_at":"2026-02-06T00:13:07.417Z","updated_at":"2026-02-06T00:13:10.239Z","avatar_url":"https://github.com/kpiljoong.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## DServer\n\nDServer is a lightweight, configurable, and dynamic mock server built in Go. It allows developers to simulate RESTful APIs for testing and development purposes, using a simple configuration file.\n\n### Features\n- **Dynamic Routing**: Easily define API routes with support for different methods like GET, POST, etc.\n- **JSON Response**: Serve customizable JSON responses out of the box.\n- **Delay Simulation**: Simulate delays globally or at the per-response level to test timeout handling in clients.\n- **Hot Reloading**: Automatically reloads configuration when the file is updated, ensuring seamless development.\n- Fallback Logic:\n  - Use a global `response_body` if no `responses` array is provided.\n  - Apply global defaults for `status_code` and `content_type` and `delay_ms` where not explicitly overridden in responses.\n\n### Prerequisites\n- **Go**: Ensure you have Go (version 1.21 or higher) installed. [Install Go](https://golang.org/doc/install).\n\n### Installation\n1. Clone the repository:\n```bash\ngit clone https://github.com/kpiljoong/dserver.git\ncd dserver\n```\n2. Build the binary:\n```bash\ngo build -o dserver\n```\n3. Alternatively, run directly:\n```bash\ngo run main.go\n```\n\n### Usage\n#### Configuration File (config.toml)\nDefine your API endpoints in a `config.toml` file. Example:\n```toml\n[[routes]]\npath = \"/api/v1/resource\"\nmethod = \"GET\"\nstatus_code = 200                   # Global status code\ndelay_ms = 500                      # Global delay in milliseconds\ncontent_type = \"application/json\"   # Global content type\nresponse_body = \"\"\"{\n  \"message\": \"Fallback response\"\n}\"\"\"\n\n[[routes]]\npath = \"/api/v1/resource\"\nmethod = \"POST\"\nstatus_code = 201\ncontent_type = \"application/json\"\nresponses = [\n  { query = {}, response_body = \"\"\"{ \"message\": \"Default resources\" }\"\"\" },\n  { query = { \"type\" = \"active\" }, delay_ms = 1000, response_body = \"\"\"{ \"message\": \"Active resources\" }\"\"\" },\n  { query = { \"type\" = \"inactive\" }, response_body = \"\"\"{ \"message\": \"Inactive resources\" }\"\"\" }\n]\n```\n\n#### Running the Server\nStart the server with:\n```bash\n./dserver -config=config.toml -port=8080\n```\n\nFlags:\n- `-config`: Path to the configuration file (default: `config.toml`).\n- `-port`: Port to run the server on (default: `8080`).\n- `-verbose`: Enable verbose logging (default: `false`).\n\nExample:\n```bash\n./dserver -config=custom-config.toml -port=9090 -verbose\n```\n\n### Features in Detail\n\n#### Global Defaults\nDServer supports default values at the `[[routes]]` level:\n- `status_code`: Used for all responses unless explicitly overridden.\n- `content_type`: Global content type for the route.\n- `delay_ms`: Default delay applied if not overridden in individual response.\n\n#### Per-Response Overrides\nIndividual responses can override the global defaults:\n- `status_code`\n- `content_type`\n- `delay_ms`\n\n#### Fallback to `response_body`\nIf no `responses` array is provided, the server falls back to the `response_body` defined at the `[[routes]]` level.\n\n#### Hot Reloading\nDServer automatically reloads the configuration file when it is updated. Simply edit the `config.toml` file, and the changes will be applied without restarting the server.\n\n### Development\n#### Running Tests\nRun the test suite:\n```bash\ngo test ./...\n```\n\n### Adding New Features\nContributions are welcome! Feel free to open a pull request or create an issue for feature requests.\n\n### License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n### Acknowledgements\n- Built with [Go](https://golang.org/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpiljoong%2Fdserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkpiljoong%2Fdserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpiljoong%2Fdserver/lists"}