https://github.com/benmezger/httmock
A minimal local HTTP testing and prototyping server
https://github.com/benmezger/httmock
golang http httpmock httpserver testing-tools
Last synced: 6 months ago
JSON representation
A minimal local HTTP testing and prototyping server
- Host: GitHub
- URL: https://github.com/benmezger/httmock
- Owner: benmezger
- Created: 2020-09-09T12:36:03.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-25T15:07:22.000Z (about 4 years ago)
- Last Synced: 2023-03-02T23:31:37.923Z (about 2 years ago)
- Topics: golang, http, httpmock, httpserver, testing-tools
- Language: Go
- Homepage:
- Size: 40 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# README
`httmock` allows local testing and prototyping by mocking a HTTP server from a file based specification.
## Installing
1. Clone this repository: `git clone https://github.com/benmezger/httmock`:
2. Run `make install`## Running
Make sure you have a `.http.yaml` in your current directory or pass a custom filename with `--api-file`
- `httmock serve` or `httmock --api-file serve`
Use `httmock serve --host localhost:8000` for using a different host/port.
### Listing routes
For listing routes with their available params, use:
- `httmock list` or `httmock --api-file list`
## HTTP file syntax
For an example of the file structure, see [example-http.yaml](example-http.yaml).
## TODOs
- Handle context base requests and responses
## Example
Run `httmock` with the [example](example-http.yaml) file
Then run curl against the defined URL paths:- `curl -X GET http://localhost:8000/?name=name-param -d '{"msg": "Body of GET request"}'`
`{"msg": "Hello, from / GET response"}`