当前位置:网站首页>[test platform development] 20. Complete the function of sending interface request on the edit page
[test platform development] 20. Complete the function of sending interface request on the edit page
2022-07-23 14:51:00 【Test notes of biting and crying apples】
be based on springboot+vue Test platform of ( Hand training program ) Development continues to update .
Today, I finally reconstructed all the functions I have done .
The front end has been slightly adjusted , It's a control that adds and deletes parameters dynamically , I was 3 individual tab Reuse a component , Later, I found some problems , Finally, I decided to write separately .

Another focus today is to redo the back-end function of editing page sending interface request . This function existed before refactoring , But now I think the previous ones are not compatible enough .
Because I have recently accessed some of the opening of Feishu in my work API, It is found that the input parameters of some interfaces are composed , such as post In request , Existing query parameters , There is also a request body .
So I combed it again , Try to support various parameter combinations :
- Without any parameters
- Only param Query parameters
- Only rest Path parameter
- Only body Parameters
- meanwhile param + body
- meanwhile rest + body
If you ask for a method , For the time being, we should support get And post this 2 The most common . Last , I've branched out all kinds of judgments , Make sure there is nothing wrong .

Function realization
Next, record the implementation of the function . The idea is simple :
- Acquisition and processing of some necessary parameters
- Judgment of different request methods
- Further judge different parameter combinations , To send http Interface processing .
With http The client is hutool Framework of the , The code is located here in the project ,93 Line back .

First , The main method deals with some necessary input parameter information , such as method、header、 And get the parameters in the form .

Next, go to the judgment of the request method , Then further judge the various types of parameters submitted by the front end , Here I took it out and wrote 2 A way to judge empty .

With get Methods as an example , Now I can judge who the parameters actually submitted are .

Determine the parameter type , It can be dealt with pertinently , The most troublesome thing here is rest Processing of path parameters , The path parameters submitted by my front end are wrapped in curly braces {name}, So be right url Deal with it again .

After splicing , You can directly initiate the request .
Here Be careful Yes. , stay hutool Of http The client , I participate in the use body() I will put form() The parameter of , So when processing the combination of request body parameters , Only query parameters or path parameters , All processing requests url On . such as , This is to deal with param+body The combination of , Manual handle param Parameter splicing to url On .

Nothing else is special , stay post I don't think it's necessary to support so many situations , So it is only compatible 3 In this case .

At present, it is only an appeal of function realization , There is also a lack of exception handling , Follow up slowly . Next, we will continue to develop new functions , In the process, I will also take some changes I recorded bug .
The latest code at the front and back ends has been updated to the branch , If you also want to start children's shoes, you can reply on the official account 【 Test platform 】, You can get the address and development records of a series of articles .
边栏推荐
猜你喜欢

基于EFR32MG24的AI 加速度姿势识别体验
![[WinForm] desktop program implementation scheme for screenshot recognition and calculation](/img/9f/e67af4386cff9febf0fb5203da03f0.jpg)
[WinForm] desktop program implementation scheme for screenshot recognition and calculation

Detailed tutorial of typora drawing bed configuration
![[applet automation minium] III. element positioning - use of wxss selector](/img/ec/51eadd08bea18f8292aa3521f11e8a.png)
[applet automation minium] III. element positioning - use of wxss selector

【测试平台开发】二十、完成编辑页发送接口请求功能

QT document reading notes audio example analysis

LeetCode-227-基本计算器||

Yunna | how to manage the fixed assets of the company? How to manage the company's fixed assets better?

运维高级作业03

Yunna - how to strengthen fixed asset management? How to strengthen the management of fixed assets?
随机推荐
LZ77 file compression
反射调用事务方法导致事务失效
String function of MySQL function summary
[software test] MQ abnormal test encountered in disk-to-disk work
Palindrome related topics
(重链剖分)魔法树
【无标题】测试【无标题】测试
linux定时备份数据库脚本
什麼是Per-Title編碼?
【无标题】
【软件测试】盘一盘工作中遇到的 MQ 异常测试
Transferred from Yuxi information disclosure: products such as mRNA covid-19 vaccine and Jiuzhou horse tetanus immunoglobulin are expected to be on the market within this year.
【论文笔记】基于分层深度强化学习的移动机器人导航方法
因为资源限制,导致namenode启动失败,报错unable to create new native thread
【C語言】猜數字小遊戲+關機小程序
一道代码题看 CommonJS 模块化规范
Detailed tutorial of typora drawing bed configuration
Which is a good fixed asset management system? What are the fixed asset management platforms?
俄方希望有效落实农产品外运“一揽子”协议
Qt|模仿文字浮动字母