.NET global tool that hosts a Routes.json file and response resources as a local mock HTTP API.
dotnet tool install -g Devlead.Testing.MockHttp.Tooldotnet mockhttp serve <RESOURCES> [--port 5080] [--url http://127.0.0.1:5080] [--match-host]serve is the default command, so <RESOURCES> can be passed directly.
<RESOURCES>is a directory that containsRoutes.jsonand the response files it references.--portbindshttp://127.0.0.1:<port>(default 5080).--urloverrides--portand uses the URL authority only.--match-hostrequires the requestHostto match the host in each routeAbsoluteUri. By default only HTTP method, path, and query are matched so a client can use the mock as itsBaseAddress.
Point an HttpClient at the listen URL:
dotnet mockhttp serve ./Resources --port 5080var client = new HttpClient { BaseAddress = new Uri("http://127.0.0.1:5080") };
var response = await client.GetAsync("/index.txt");curl http://127.0.0.1:5080/index.txt
curl -i -H "Authorization: Bearer AccessToken" http://127.0.0.1:5080/login/secret.jsonThose requests match Routes.json entries whose AbsoluteUri values are https://example.com/index.txt and https://example.com/login/secret.json.
While the host is running, the console shows a live table of configured routes and recent requests. Open http://127.0.0.1:5080/inspect for the inspect page: route enable/disable, request activity, and DevTools-style request/response headers and bodies. GET /inspect/api returns the same snapshot as JSON.
The JSON contract is the same as Devlead.Testing.MockHttp: methods, AbsoluteUri, optional authorization, request-header-specific responses, status codes, and EnableRequests / DisableRequests.
ContentResource values such as Example.Login.Secret.json resolve to Example/Login/Secret.json under the resources directory.