SpringCloud HTTP顶级元素

2023-12-12 18:04 更新

在合同定义的顶级闭合中可以调用以下方法。requestresponse是必需的。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标签/方法。例如,值5priority的优先级高于值10priority更高priority与{值4141 /}优先级。


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号