SpringCloud HTTP頂級(jí)元素

2023-12-12 18:04 更新

在合同定義的頂級(jí)閉合中可以調(diào)用以下方法。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:

...
如果要使合同具有較高的優(yōu)先級(jí),則需要將較低的數(shù)字傳遞給priority標(biāo)簽/方法。例如,值5priority的優(yōu)先級(jí)高于值10priority。更高priority與{值4141 /}優(yōu)先級(jí)。


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)