Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ndolestudio/httpmock
HTTP Mock Server
https://github.com/ndolestudio/httpmock
http-mock-server http-server mock mock-server rails-application
Last synced: 3 months ago
JSON representation
HTTP Mock Server
- Host: GitHub
- URL: https://github.com/ndolestudio/httpmock
- Owner: NdoleStudio
- License: agpl-3.0
- Created: 2024-02-10T09:59:34.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-10-01T01:39:47.000Z (3 months ago)
- Last Synced: 2024-10-10T04:42:16.606Z (3 months ago)
- Topics: http-mock-server, http-server, mock, mock-server, rails-application
- Language: Ruby
- Homepage: https://httpmock.dev
- Size: 421 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
httpmock
========[![Build](https://github.com/NdoleStudio/httpmock/actions/workflows/ci.yml/badge.svg)](https://github.com/NdoleStudio/httpmock/actions/workflows/ci.yml)
[![GitHub contributors](https://img.shields.io/github/contributors/NdoleStudio/httpmock)](https://github.com/NdoleStudio/httpmock/graphs/contributors)
[![GitHub license](https://img.shields.io/github/license/NdoleStudio/httpmock?color=brightgreen)](https://github.com/NdoleStudio/httpmock/blob/master/LICENSE)
[![Codecov](https://codecov.io/gh/NdoleStudio/httpmock/branch/main/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/httpmock)
[![Better Stack Badge](https://uptime.betterstack.com/status-badges/v1/monitor/1185i.svg)](https://uptime.betterstack.com/?utm_source=status_badge)
![Docker Pulls](https://img.shields.io/docker/pulls/ndolestudio/httpmock)This is a mock http server which can be used to test HTTP requests and responses when building an HTTP client.
You can also use it to mock a backend API in your frontend app e.g in in situations where you're still waiting for the
backend API to be ready.## Server
You can use the mock server for free at httpmock.dev. The server will return the data which you specify using custom http request headers.
The server will use these headers to generate the response to your http request.- `response-body`: This can any string which will be returned as the response body by the server
- `response-headers`: This should be a JSON array of headers that will be returned by the server for the request
- `response-status`: This is the HTTP status code of the response e.g `500`, `200`, `404`
- `response-delay`: This is the time in milliseconds that the server will wait before returning the response e.g `1000` for 1 second. The max delay you can set is 10 seconds. If you provide a larger delay, it will capped at 10 seconds.```bash
curl -X GET https://httpmock.dev/server \
-H 'response-body: {"id": 12334, "name": "e.g John Doe"}' \
-H 'response-headers: [{"Content-Type":"application/json"}]' \
-H 'response-status: 200'
```or this is an example with javascript
```js
fetch("https://httpmock.dev/server", {
headers: {
"response-body": '{"id": 12334, "name": "John Doe"}',
"response-headers": '[{"Content-Type":"application/json"}, {"x-request-id":"dea576ed-ba18-4dd3-baa7-7c865c14b444"}]',
"response-status": 200,
"response-delay": 1000
},
method: "GET",
});
```## Credits
- Color Palette: https://coolors.co/palette/606c38-283618-fefae0-dda15e-bc6c25
- Icon: https://www.svgrepo.com/svg/361904/json-ld## License
This project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 - see the [LICENSE](LICENSE) file for details