分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

Mock2 moco框架的http协议get方法Mock的实现

发布时间:2023-09-06 02:14责任编辑:熊小新关键词:http

首先在Chapter7文件夹下再新建一个startGet.json

startget.json代码如下,因为是get请求,所以要写method关键字,有两个,一个是有参数,一个是无参数的请求。

[ ?{ ???"description":"模拟一个没有参数的get请求", ???"request":{ ?????"uri":"/getDemo", ?????"method":"get" ???}, ???"response":{ ?????"text":"这是一个没有参数的get请求" ???} ?}, ?{ ???"description":"模拟一个带参数的get请求", ???"request":{ ?????"uri":"/getwithparam", ?????"method":"get", ?????"queries":{ ???????"name":"huhanshan", ???????"age":"18" ?????} ???}, ???"response":{ ?????"text":"这是一个带参数的get请求,胡汉山又回来了" ???} ?}]

启动mock服务器; java -jar ./moco-runner-0.12.0-standalone.jar http -p 8888 -c startupGet.json

然后在浏览器访问:localhost:8888/getDemo      这是一个不带参数的请求

log:

然后也可以访问:http://localhost:8888/getwithparam?name=huhanshan&age=18   这是一个带参数的请求吧

log:

Mock2 moco框架的http协议get方法Mock的实现

原文地址:https://www.cnblogs.com/peiminer/p/9636356.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved