Mockice is a simple HTTP service that provides configurable endpoints. Use it for testing or serving static content.
To install Mockice, run:
go get -u -v github.com/hudymi/mockice
To use Mockice, you can run its latest version, run its latest Docker image, or run it from sources. In each case, by default, the service listens on port 8080
and has one endpoint - http://localhost:8080/hello
.
To run Mockice latest version, install Mockice with the command from the Installation section and run:
mockice --verbose
To run Mockice latest Docker image, use the following command:
docker run -p 8080:8080 hudymi/mockice:latest --verbose
To run Mockice from sources, use the following command:
GO111MODULE=on go run main.go --verbose
The table contains the command line parameters available for the service:
Name | Description | Default Value |
---|---|---|
--config |
A path to the configuration file. If not provided, the default configuration is used. | |
--verbose |
Enables verbose logging. | false |
By default, in every interface Mockice listens on port 8080
and has one endpoint - http://localhost:8080/hello
. If you provide any configuration, the default endpoint is disabled.
The configuration file must be in the yaml
format. See the config structure for the up-to-date list of the available fields.
# The service address
address: :8080
# The list of endpoints
endpoints:
- name: hello # Name of the endpoint
# The list of valid methods, if not set validation is skipped
methods:
- GET
- POST
# Default HTTP response code, if not provided 200
defaultResponseCode: 200
# Default response content
defaultResponseContent: "Sample service"
# Default response content-type, if not provided "text/plain; charset=utf-8"
defaultResponseContentType: text/plain; charset=utf-8
# Path to the file that is returned by default, if provided then defaultResponseContent is ignored
defaultResponseFile: "mockice/index.html"