You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,12 @@ To run http-mockery you'll need to have a config file. Example is available [her
7
7
Config file needs to include an `endpoints` config if you want to respond with anything else than 404 Not Found. Default listening address is "0.0.0.0:8080", but this can be changed with `listen_ip` and `listen_port`.
8
8
Default config file is `config.json` in the same directory as the application, but it can also be defined with `HTTP_MOCKERY_CONFIG` env variable.
9
9
10
-
Endpoint config needs to have atleast `uri`, `method` and `response_code` to operate normally. If you want the endpoint to return any JSON, you'll also need to provide the name of a `template` file, and `variables` configuration if the template includes anything to replace. Replacable variables are marked with < and >, e.g. `<replace_me>`. Matching variable must then be found (see examples). Value can be either provided in the config as `value` or as an environment variable where the env var name should be included in the variable config as `env_var`. Both `value` and `env_var` can be defined, but env_var always has precedence.
11
-
10
+
Endpoint config needs to have atleast `uri`, `method` and `response_code` to operate normally. If you want the endpoint to return any JSON, you'll also need to provide the name of a `template` file, and `variables` configuration if the template includes template tags. Replacable variables are marked with `<` and `>` tags, e.g. `<replace_me>`. Matching `env_var` and `value` variables must then be found (see examples), `header` variables are treated as optional.
11
+
Following template tag value providers are supported (order by priority):
12
+
-`env_var` uses environment variable's value to replace tag
13
+
-`value`, replaces template tag with raw value
14
+
-`header`, uses HTTP request header field value to replace template tag
15
+
12
16
Endpoint `type` is defaulted to `normal` but can also be set as `regexp`. It allows for standard regular expressions in the `uri` to match more specific use cases. Endpoints are checked in a given order and first matching endpoint (with correct `uri` and `response_code`) will be used.
13
17
14
18
Request and response bodies from requests can be logged with their relevant config options under `logging`, example [here](examples/config-example.json). Request & response content logging can also be toggled with env variables `HTTP_MOCKERY_REQUEST_CONTENTS` and `HTTP_MOCKERY_RESPONSE_CONTENTS` Endpoint-specific secrets are censored from logs.
0 commit comments