我正在使用stubby4j对一些服务端点进行存根。目前,我正在处理那些非常重且不太复杂的服务,但我想将其称为其他端点的真正服务。
就像这样:
/heavy-call-1 => stub service
/heavy-call-2 => stub service
/lightweight-call-1 => real service
/lightweight-call-2 => real service有什么方法可以用这个工具实现这一点,还是应该考虑使用不同的工具?
发布于 2016-12-20 14:24:29
实际上,您可以第一次调用真实的服务并记录响应,因此下一个请求将使用这个记录的响应。可以这样做的方法是在yaml文件中的存根响应正文中指定一个URL,如下所示:
- request:
url: /1.1/direct_messages.json
query:
since_id: 240136858829479935
count: 1
response:
headers:
content-type: application/json
body: https://api.twitter.com/1.1/direct_messages.json?since_id=240136858829479935&count=1您可以在短短的github文档中找到更多信息:https://stubby4j.com/#key-features和Howto.html#记录和回放
希望这能有所帮助!
发布于 2018-11-08 12:41:27
你在利用webpack吗?如果是这样,您可以匹配不同的域。例如:
const config = merge(common, {
devtool: 'inline-source-map',
mode: 'development',
devServer: {
historyApiFallback: true,
port: 3000,
hot: true,
proxy: [
{ path: '/heavy-all-1 ', target: 'http://localhost:8882' }, //stubby
],
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
}),
],
});没有所描述的前缀的URL也不会被删除。
https://stackoverflow.com/questions/41234556
复制相似问题