Skip to content

Commit 518fd03

Browse files
committed
add doc
1 parent f9f3a54 commit 518fd03

File tree

13 files changed

+103
-12
lines changed

13 files changed

+103
-12
lines changed

README.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,92 @@
1-
# api-debugger
2-
API debugger that supports custom encryption
1+
# API debugger
2+
3+
A like Postman API debugger that supports custom encryption.
4+
5+
一个类似Postman的支持自定义加密传输的后台API接口调试工具.
6+
7+
![1](./img/1.png)
8+
9+
## 特征
10+
11+
- 支持可扩展的自定义的参数加密方式.
12+
- 使用数据库按项目分开保存BaseUrl和接口Api列表,一次配置,持续使用.
13+
- 支持多个BaseUrl点击切换.请求参数动态增删.
14+
- 支持默认请求参数配置,该项目下的每一个接口请求都会默认添加默认请求参数.
15+
- 使用[Json Editor Online](http://jsoneditoronline.org/)展示请求结果json,美观,易用.
16+
- 支持简单的接口压力测试
17+
18+
## 安装
19+
20+
点击下载最新release包.在安装了JDK1.8或者JRE1.8的电脑上,双击jar包直接运行.
21+
22+
- JDK下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
23+
- 如果在Windows系统下无法正常使用的话.需要安装 [Microsoft Visual C++ 2015 Redistributable (x64)](http://www.microsoft.com/en-us/download/details.aspx?id=53587)
24+
- 默认支持mac和windows
25+
26+
## 使用
27+
28+
1. 创建项目:菜单栏 <kbd>Project</kbd> > <kbd>new</kbd>> <kbd>输入项目名称</kbd>><kbd>OK</kbd>
29+
30+
![2](/img/2.png)
31+
32+
看到当前打开的项目就OK了.
33+
34+
2. 输入BaseUrl,点击保存生效.
35+
36+
3. 输入接口Url,最后的请求Url = baseUrl+接口Url.
37+
38+
4. 选择请求方法,现在只做了POST和GET方法.
39+
40+
5. 选择加密方式.default是没有加密,直接发送.
41+
42+
6. Add Row 添加一个请求参数.
43+
44+
7. 填写请求参数的key和value,这里需要注意的是需要表格失去焦点变为蓝色之后,这个值才会被保存生效.
45+
46+
![3](/img/3.png)
47+
48+
8. 点击小飞机发送请求.请求的相关信息在右上部分的Request Information中显示.请求结果在下面的Json Editor中显示.
49+
50+
9. 请求成功返回后这个接口的url,方法,加密方式和请求参数会自动保存到数据库中.添加其他请求只需直接输入接口url和参数,方法等配置进行测试,前一个接口的信息不会被覆盖.
51+
52+
## 自定义加密扩展
53+
54+
该App界面使用Java实现,逻辑使用Kotlin实现.内部数据库为[ObjectBox](https://objectbox.io/),需要达到自定义加密的目的的话.需要自行扩展.
55+
56+
1. **[重点]**fork仓库clone到本地后,使用IDEA打开.下载 jxbrowser-mac-6.20.jar (链接:https://pan.baidu.com/s/1B3ErPhbrocIaGhu3zg8RMA 密码:1wn9 ) 拷贝到lib中(太大了不好传,虽然名字里有mac但是windows和mac都支持,linux尚未测试,如有linux使用需求,请自行查找linux版).
57+
58+
2. 在build生成out文件夹后,解压jsonView.rar到`\out\production\classes\com\longforus\apidebugger\ui`目录下(这样生成jar包的时候才会把这些文件包含到jar包中,gradle应该有别的更优雅的方法,目前尚未实现).
59+
60+
3. 实现`com.longforus.apidebugger.encrypt.IEncryptHandler`抽象类.可参考默认实现类`com.longforus.apidebugger.encrypt.DefaultEncryptHandler`
61+
62+
```kotlin
63+
/**
64+
* Created by XQ Yang on 8/30/2018 5:11 PM.
65+
* Description : 加密处理
66+
*/
67+
abstract class IEncryptHandler {
68+
//这个加密类型的code,同一工程不允许出现相同的
69+
abstract val typeCode:Int
70+
//显示在界面上的名字
71+
abstract val title: String
72+
//实现get方法的参数加密
73+
abstract fun onGetMethodEncrypt(params: Map<String, String>?, builder: Request.Builder, url: String)
74+
//实现post方法的参数加密
75+
abstract fun onPostMethodEncrypt(params: Map<String, String>?, builder: Request.Builder, url: String): RequestBody
76+
override fun toString(): String {
77+
return title
78+
}
79+
}
80+
```
81+
82+
4. 新建一个实现类的实例添加到`com.longforus.apidebugger.MyValueHandler#getEncryptImplList`中.第0个为默认显示item.现在就可以在加密方式中选择你自己的加密方式了.
83+
84+
```kotlin
85+
86+
object MyValueHandler {
87+
val encryptImplList = listOf<IEncryptHandler>(YourEncryptHandler(), DefaultEncryptHandler())
88+
}
89+
```
90+
91+
5. 打包可运行的jar包请自行搜索.
92+

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ dependencies {
6767

6868
// enable debug output for plugin
6969
objectbox {
70-
debug true
70+
debug false
7171
}
7272
// enable debug output for annotation processor
7373
tasks.withType(JavaCompile) {
74-
options.compilerArgs += [ "-Aobjectbox.debug=true" ]
74+
options.compilerArgs += [ "-Aobjectbox.debug=false" ]
7575
options.encoding = "UTF-8"
7676
}

img/1.png

165 KB
Loading

img/2.png

9.7 KB
Loading

img/3.png

22 KB
Loading

jsonView.zip

5.43 KB
Binary file not shown.

src/main/java/com/longforus/apidebugger/ui/MainPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public MainPanel(String title) throws HeadlessException {
139139
$$$setupUI$$$();
140140

141141
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
142-
String filename = getClass().getResource("") + "send.png";
142+
String filename = getClass().getResource("") + "jsonView/send.png";
143143
try {
144144
ImageIcon icon = new ImageIcon(new URL(filename));
145145
setIconImage(icon.getImage());
-5.64 KB
Binary file not shown.

src/main/kotlin/com/longforus/apidebugger/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import java.math.BigInteger
1313
*/
1414

1515
lateinit var mainPanel: MainPanel
16-
val appName = "Fec Api debugger"
16+
val appName = "Api debugger"
1717

1818

1919
fun main(args: Array<String>) {

src/main/kotlin/com/longforus/apidebugger/MyValueHandler.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ import java.awt.datatransfer.StringSelection
1717

1818
object MyValueHandler {
1919

20-
const val PARAME_TABLE_ROW_COUNT = 15
21-
2220

2321
val encryptImplList = listOf<IEncryptHandler>(kzEncryptHandler(), DefaultEncryptHandler())
22+
// val encryptImplList = listOf<IEncryptHandler>( DefaultEncryptHandler())
2423
val mGson =GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create()
2524

2625
var curProject: ProjectBean? = null

0 commit comments

Comments
 (0)