Skip to content

Commit

Permalink
synchronized content from http api to socket api
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamhead committed Apr 30, 2015
1 parent 8f4dd6a commit 8374c01
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion moco-doc/socket-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ That means if we get the expected request and then return our response. Now, you

**WARNING** the json configuration below is just a snippet for one pair of request and response, instead of the whole configuration file.

## Description as comment
**@Since 0.7**

In all JSON APIs, you can use **description** to describe what is this session for. It's just used as comment, which will be ignored in runtime.

```json
[
{
"description": "any response",
"response": {
"text": "foo"
}
}
]
```

## Request

### Content
Expand Down Expand Up @@ -622,4 +638,28 @@ server.request(by(text("template"))).response(template("${'foo'}", "foo", jsonPa
}
```

Other extractors, e.g. xpath also work here.
Other extractors, e.g. xpath also work here.

### File Name Template

Template can also be used in file name, thus response can be different based on different request.

* Java
```java
server.response(file(template("${req.headers['foo'].txt")));
```

* JSON
```json
[
{
"response": {
"file": {
"name": {
"template": "${req.content}.txt")"
}
}
}
}
]
```

0 comments on commit 8374c01

Please sign in to comment.