Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
iss #2: ...
Browse files Browse the repository at this point in the history
  • Loading branch information
maizy committed Dec 1, 2014
1 parent ffcbac5 commit 9ebae51
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
70 changes: 68 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ For use only in dev or testing environments.

If you want to bind ports <= 1024 use `sudo`.

See sample config definition at [examples/example.json](examples/example.json) and
[some more useful examples](examples/).
See sample config definition [bellow](#use_cases).

## Requirements

Expand All @@ -36,6 +35,73 @@ python setup.py install
[![Coveralls, Coverage Statusm master branch](https://img.shields.io/coveralls/maizy/zaglushka.svg)](https://coveralls.io/r/maizy/zaglushka?branch=master)


<a name="use_cases"/>
## Some use cases

### Simple error stub for any request url

```js
//config.json
{
"urls": [
{
"path_regexp": ".*",
"code": 500,
"response": "<error>Pechal'ka exception: db connection error</error>",
"headers" : {
"Server": "MyBackendServer/0.5"
}
}
]
```
```bash
zaglushka.py --ports=5000,5001,5002 --config=config.json
```
```
curl -v http://127.0.0.1:5000/any_url
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> GET /any_url HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 127.0.0.1:5000
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
< Content-Length: 55
* Server MyBackendServer/0.5 is not blacklisted
< Server: MyBackendServer/0.5
<
* Connection #0 to host 127.0.0.1 left intact
<error>Pechal'ka exception: db connection error</error>
```
Server watched for any changes in stub files or config and reload automatically.
### Emulate backend responses with `response_file` and `headers_file`
```js
//config.json
{
"stubs_base_path": "./stubs",
"urls": [
{
"path": "/some/page.html",
"response_file": "page1.html",
"headers_file": "page1.headers"
}
]
```
### More complicated match rules
...
### Proxy all responses to real server, but stub someone with error
...
## Issues
* [issues for v0.1](https://github.com/maizy/zaglushka/issues?q=is%3Aopen+is%3Aissue+milestone%3A0.1)
Expand Down
2 changes: 1 addition & 1 deletion examples/always_500.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{
"path_regexp": ".*",
"response": "Internal server error",
"response": "<error>Pechal'ka exception: db connection error</error>",
"code": 500,
"headers" : {
"Server": "MyBackendServer/0.5"
Expand Down

0 comments on commit 9ebae51

Please sign in to comment.