{"id":43154632,"url":"https://github.com/joshcarp/servermock","last_synced_at":"2026-02-01T00:34:00.887Z","repository":{"id":57575786,"uuid":"356126525","full_name":"joshcarp/servermock","owner":"joshcarp","description":"mock grpc and http servers with ease","archived":false,"fork":false,"pushed_at":"2023-03-07T02:41:22.000Z","size":102,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-12T05:24:48.619Z","etag":null,"topics":["golang","grpc","http","mock"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshcarp.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":"2021-04-09T03:47:11.000Z","updated_at":"2023-03-05T08:37:40.000Z","dependencies_parsed_at":"2024-06-21T01:07:56.617Z","dependency_job_id":"ef016e57-7234-4af6-b940-a2bf3171232c","html_url":"https://github.com/joshcarp/servermock","commit_stats":null,"previous_names":["joshcarp/mirror","joshcarp/dmt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joshcarp/servermock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcarp%2Fservermock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcarp%2Fservermock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcarp%2Fservermock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcarp%2Fservermock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshcarp","download_url":"https://codeload.github.com/joshcarp/servermock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcarp%2Fservermock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28962077,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T23:03:11.038Z","status":"ssl_error","status_checked_at":"2026-01-31T22:56:44.691Z","response_time":128,"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":["golang","grpc","http","mock"],"created_at":"2026-02-01T00:33:55.856Z","updated_at":"2026-02-01T00:34:00.883Z","avatar_url":"https://github.com/joshcarp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\n\u003c/p\u003e\n\n\n\u003ch1 align=\"center\"\u003eservermock\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Status](https://img.shields.io/badge/status-active-success.svg)]()\n[![GitHub Issues](https://img.shields.io/github/issues/joshcarp/servermock)](https://github.com/joshcarp/servermock/issues)\n[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/joshcarp/servermock)](https://github.com/joshcarp/servermock/pulls)\n[![License](https://img.shields.io/badge/license-apache2-blue.svg)](/LICENSE)\n\n\u003c/div\u003e\n\n---\n\n\n## 📝 Table of Contents\n- [About](#about)\n- [Getting Started](#getting_started)\n- [Usage](#usage)\n- [Authors](#authors)\n- [Acknowledgments](#acknowledgement)\n\n## 🧐 About \u003ca name = \"about\"\u003e\u003c/a\u003e\n\nservermock is a go package that can be used to mock out http or grpc servers simply without any external server implementations.\n\n\n## 🚀 Usage \u003ca name = \"usage\"\u003e\u003c/a\u003e\n\n### Inline in golang\n1. Start a server\n```golang\nerr := servermock.Serve(ctx, Printf, \":8000\")\n```\n2. Set the response\n```golang\nerr = servermock.SetResponse(\"http://localhost:8000\", servermock.Request{\n\t\tPath:       \"/foo.service.bar.SomethingAPI/GetWhatever\",\n\t\tBody:       []byte(`{\"Hello\": \"true\"}`),\n\t\tStatusCode: 200,\n\t})\n```\n3. Send a request\n```golang\nresp, err := http.Get(\"http://localhost:8000/foo.service.bar.SomethingAPI/GetWhatever\")\n// {\"Hello\": \"true\"}\n```\n\n### In a docker container\n1. Run the docker container\n```bash\ndocker run -p 8000:8000 joshcarp/servermock\n```\n2. Set the response conforming to the `servermock.Request` type\n```bash\ncurl --header \"Content-Type: application/json\" --header \"SERVERMOCK-MODE: SET\" --request POST --data '{\"path\":\"/foo.service.bar.SomethingAPI/GetWhatever\",\"body\":\"eyJIZWxsbyI6ICJ0cnVlIn0=\",\"status_code\":200' http://localhost:8000/foo.service.bar.SomethingAPI/GetWhatever\n```\n3. Send a request\n```bash\ncurl localhost:8000/foo.service.bar.SomethingAPI/GetWhatever\n\u003e {\"Hello\": \"true\"}                                                                                                  \n```\n\n### gRPC vs REST servers\n\nSetting data always occurs over http 1.0 using the json payload, gRPC servers are, after all, just servers that return some bytes.\n\nsee [example/example_test.go](example/example_test.go) for full examples.\n\n## ✍️ Authors \u003ca name = \"authors\"\u003e\u003c/a\u003e\n- [@joshcarp](https://github.com/joshcarp)\n\n## 🎉 Acknowledgements \u003ca name = \"acknowledgement\"\u003e\u003c/a\u003e\n- [@emmaCullen](https://github.com/emmaCullen) had the original idea for this package.\n- [github.com/dnaeon/go-vcr](https://github.com/dnaeon/go-vcr) is similar but different; whilst any network traffic can be recorded and replayed, servermock tries tosimplify mocking of servers in unit tests/contexts where writing a specific server implementation is a little too much. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshcarp%2Fservermock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshcarp%2Fservermock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshcarp%2Fservermock/lists"}