zoukankan      html  css  js  c++  java
  • Mock2 moco框架的http协议get方法Mock的实现

    首先在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:

  • 相关阅读:
    Evensgn 的债务
    Passward
    拯救莫莉斯
    文艺平衡树
    Fliptile 翻格子游戏
    Making the Grade (bzoj1592)
    紧急疏散evacuate
    Password
    [NOIP2015]斗地主
    运输问题1
  • 原文地址:https://www.cnblogs.com/peiminer/p/9636356.html
Copyright © 2011-2022 走看看