{"id":38702333,"url":"https://github.com/pokatomnik/mockers","last_synced_at":"2026-01-17T10:50:26.962Z","repository":{"id":326245187,"uuid":"1095072280","full_name":"pokatomnik/mockers","owner":"pokatomnik","description":"Blazingly 🤡 fast HTTP mocking server written in Rust","archived":false,"fork":false,"pushed_at":"2026-01-11T15:31:47.000Z","size":631,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"dungeon-master","last_synced_at":"2026-01-11T18:45:34.763Z","etag":null,"topics":["clap","hyper","mock","reqwest","rust","server","tokio"],"latest_commit_sha":null,"homepage":"https://github.com/pokatomnik/mockers","language":"Rust","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/pokatomnik.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-12T14:54:38.000Z","updated_at":"2026-01-11T15:31:48.000Z","dependencies_parsed_at":"2025-12-16T22:06:19.307Z","dependency_job_id":null,"html_url":"https://github.com/pokatomnik/mockers","commit_stats":null,"previous_names":["pokatomnik/mockers"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pokatomnik/mockers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fmockers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fmockers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fmockers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fmockers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pokatomnik","download_url":"https://codeload.github.com/pokatomnik/mockers/tar.gz/refs/heads/dungeon-master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokatomnik%2Fmockers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28506593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T10:25:30.148Z","status":"ssl_error","status_checked_at":"2026-01-17T10:25:29.718Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["clap","hyper","mock","reqwest","rust","server","tokio"],"created_at":"2026-01-17T10:50:26.885Z","updated_at":"2026-01-17T10:50:26.947Z","avatar_url":"https://github.com/pokatomnik.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mockers - Simple HTTP Mock Server in Rust 🎯\n\n[![Rust](https://github.com/pokatomnik/mockers/actions/workflows/rust.yml/badge.svg)](https://github.com/pokatomnik/mockers/actions/workflows/rust.yml)\n\n`Mockers` is a lightweight HTTP server written in Rust for serving mock responses from files. It is designed for\ntesting, prototyping, or any scenario where you need a quick mock backend.\n\n---\n\n## Installation 🚀\n\nBuild from source using Cargo:\n\n```bash\ncargo build --release\n```\n\n## Usage 🚀\n\nRun the server using the `serve` command:\n\n```sh\nmockers serve [OPTIONS]\n```\n\n## Command-line Options 🚀\n\n| Flag               | Default     | Description                                                              |\n| ------------------ | ----------- | ------------------------------------------------------------------------ |\n| `--host`           | `127.0.0.1` | Host to listen on                                                        |\n| `--port`, `-p`     | `8080`      | Port to listen on                                                        |\n| `--verbose`, `-v`  | `false`     | Enable verbose logging                                                   |\n| `--mocks`, `-m`    | `mocks`     | Path to the directory containing mock files                              |\n| `--cors`           | `false`     | Enable CORS headers (`Access-Control-Allow-Origin: *`)                   |\n| `--delay-ms`       | `0`         | Delay (in milliseconds) for serving mock responses                       |\n| `--origin`         | [unset]     | Forward requests to another server when mock is missing by requested URL |\n| `--admin-base-url` | [unset]     | Enable admin API (see admin unit)                                        |\n\n## Mock File Structure 🚀\n\n- 💡 All files inside the mocks directory are used as responses.\n- 💡 File names determine the HTTP method:\n\n```\nuser.get       -\u003e responds to GET /user\nlogin.post     -\u003e responds to POST /login\n```\n\n- 💡 The path inside the file name (before the dot) corresponds to the URL path.\n- 💡 Both relative and absolute paths are supported for the `--mocks` flag.\n\nExample:\n\n```\nmocks/\n├─ user.get\n├─ login.post\n└─ config.put\n```\n\nThis will create the following endpoints:\n\n- 💡 `GET /user`\n- 💡 `POST /login`\n- 💡 `PUT /config`\n\n## Examples 🚀\n\nRun the server on default settings:\n\n```sh\nmockers serve\n```\n\nRun on a custom host and port with verbose logging:\n\n```sh\nmockers serve --host 0.0.0.0 --port 3000 --verbose\n```\n\nServe mocks from a custom directory with CORS enabled and 500ms response delay:\n\n```sh\nmockers serve --mocks ./api_mocks --cors --delay_ms 500\n```\n\n## Per-Directory Mock Configuration 🚀\n\nSome endpoints may require custom behavior — a delayed response, a non-200 status code, or custom headers.\nTo support this, any mock directory may optionally contain a mock-config.json file describing additional response\nparameters.\n\n### Example 🔧\n\n```json\n{\n  \"test.get\": {\n    \"delayMs\": 5000,\n    \"statusCode\": 201,\n    \"headers\": {\n      \"X-Server\": \"Mockers\"\n    },\n    \"cacheMode\": \"Overwrite\"\n  }\n}\n```\n\nGiven the file above, a request to:\n\n```\nGET http://localhost:8080/test\n```\n\nwill produce:\n\n- 💡 **5000 ms delay**\n- 💡 **HTTP 201 status**\n- 💡 **Header** `X-Server: Mockers`\n- 💡 **Body** — the content of `test.get` (or any corresponding mock file)\n- 💡 The response body will be cached into `test.get` if file `test.get` is missing (asynchronously).\n\n### Rules 🔧\n\n- 💡 The config file is optional.\n- 💡 If it doesn't exist, default behavior applies (status 200, no delay, no custom headers).\n- 💡 Keys in the config file must match mock filenames in the same directory.\n- 💡 For example, test.get configures the file test.get.\n- 💡 All fields inside each entry are optional:\n\n| Field        | Type                     | Description                                                                                                                                                                                         |\n| ------------ | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `delayMs`    | `number`                 | Artificial response delay in milliseconds                                                                                                                                                           |\n| `statusCode` | `number` (u16)           | HTTP status code                                                                                                                                                                                    |\n| `headers`    | `Record\u003cstring,string\u003e`  | Additional headers to append to the response                                                                                                                                                        |\n| `cacheMode`  | `Overwrite` or `NoCache` | If you specify the Overwrite parameter, if the mock file is missing, the request will be sent to the origin url and the body of the origin server response will be written to the missing mock file |\n\n### Example Behavior 🔧\n\nIf only some fields are provided, the server fills in the rest with defaults.\nFor example:\n\n```json\n{\n  \"user.get\": {\n    \"statusCode\": 404\n  }\n}\n```\n\nThis results in:\n\n- 💡 404 status\n- 💡 no delay\n- 💡 no custom headers\n- 💡 body loaded from `user.get`\n\n# Admin pages and API\n\nIt is also possible to manage moks in runtime. This is implemented using the REST API, which can be enabled using the\nlaunch flag `--admin-base-url`. Here you need to pass the absolute URL path, which cannot be used as a mock path, and in\nwhich the REST-endpoints and Swagger UI are located.\nExample:\n\n```sh\nmockers serve --admin-base-url /__admin\n```\n\nAll endpoints will start from the specified admin base url. There are endpoints for creating mocks in runtime, deleting\nand modifying, as well as endpoints for saving mocks from RAM to a file.\n\nTo open the Swagger UI (let's assume that we have launched `mockers` as mentioned above) you need to open the\naddress http://localhost:8080/\\_\\_admin/swagger\n\n## Notes 🚀\n\n- 💡 The server automatically resolves relative paths for mocks based on the current working directory.\n- 💡 If the specified mocks directory does not exist or is not a directory, the server will return an error.\n- 💡 Response delay can be used to simulate slow network responses.\n\n## Shout-out 🚀\n\nHuge thanks to [@Caik](https://github.com/Caik)\n, whose [Go version](https://github.com/Caik/go-mock-server) sparked the idea for this project.\nI rewrote the whole thing in Rust because apparently I enjoy suffering — and because I wanted features the original\nnever asked for.\n\nBig thanks to [bloodvez](https://github.com/bloodvez) for helping me find problems and to [silentroach](https://github.com/silentroach) for pointing out a bug and showing me mind-blowing AI experiments with Rust.\n\n## License 🚀\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokatomnik%2Fmockers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpokatomnik%2Fmockers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokatomnik%2Fmockers/lists"}