-
Notifications
You must be signed in to change notification settings - Fork 11
EN.03.07.Builtin Variables
Akinori Yamada edited this page Jan 16, 2015
·
3 revisions
There are builtin variables on Aeromock, refer to the following.
- Template data file
- JSON API data file
- routing.groovy
- data.groovy
- ajax.groovy
- variable.groovy
- Custom tag, function script
variable name | content | type | example | decription |
---|---|---|---|---|
HOST | host name Aeromock runs | java.lang.String | localhost:3183 | |
REMOTE_HOST | remote host name | java.lang.String | localhost | |
USER_AGENT | user agent string | java.lang.String | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36 | |
REFERER | referer string | java.lang.String | http://localhost:3183/mypage | |
REQUEST_URI | request uri(not include query string) | java.lang.String | /mypage/hoge | |
QUERY_STRING | query string | java.lang.String | hoge1=value1&hoge2=value2 | |
NOW | current time | java.util.Date | (Tue Jul 22 17:04:30 JST 2014) | |
PARAMETERS | query string parameter map | java.util.Map | {"hoge1":"value1", "hoge2":"value2"} | |
FORM_DATA | form data parameter map | java.util.Map | {"hoge1":"value1", "hoge2":"value2"} | Deprecated. Will be removed at 0.3.0 |
POST_DATA | post data parameter map | java.util.Map | {"hoge1":"value1", "hoge2":"value2"} | supports follows. application/json, application/x-www-form-urlencoded, multipart/form-data |
In data files, to write ${variable name}
. This expression language is Java Expression Language3(JSR-341), then possible to execute method of variables.
prop: ${REQUEST_URI}
In groovy script, write as follows. Then, output content of variable by using println method at console.
println(USER_AGENT)
if (USER_AGENT =~ /(iPhone|Android)/ ) {
return ["common", "common_sp"]
} else {
return ["common", "common_pc"]
}