SpringCloud HTTP顶级元素
在合同定义的顶级闭合中可以调用以下方法。request和response是必需的。priority是可选的。
Groovy DSL。
org.springframework.cloud.contract.spec.Contract.make {
// Definition of HTTP request part of the contract
// (this can be a valid request or invalid depending
// on type of contract being specified).
request {
method GET()
url "/foo"
//...
}
// Definition of HTTP response part of the contract
// (a service implementing this contract should respond
// with following response after receiving request
// specified in "request" part above).
response {
status 200
//...
}
// Contract priority, which can be used for overriding
// contracts (1 is highest). Priority is optional.
priority 1
}YAML。
priority: 8 request: ... response: ...
如果要使合同具有较高的优先级,则需要将较低的数字传递给priority标签/方法。例如,值5的priority的优先级高于值10的priority。更高比priority与{值4141 /}优先级。