Compare commits
2 Commits
bugfix_ale
...
pr_3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b16307b14b | ||
|
|
e8729f831d |
@@ -25,10 +25,12 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.client.methods.RequestBuilder;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import java.io.IOException;
|
||||
@@ -296,6 +298,7 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
log.error("not support the http method: {}.", httpProtocol.getMethod());
|
||||
return null;
|
||||
}
|
||||
|
||||
// params
|
||||
Map<String, String> params = httpProtocol.getParams();
|
||||
if (params != null && !params.isEmpty()) {
|
||||
@@ -303,6 +306,7 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
requestBuilder.addParameter(param.getKey(), param.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// headers
|
||||
Map<String, String> headers = httpProtocol.getHeaders();
|
||||
if (headers != null && !headers.isEmpty()) {
|
||||
@@ -332,7 +336,11 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
String value = DispatchConstants.BEARER + " " + httpProtocol.getAuthorization().getBearerTokenToken();
|
||||
requestBuilder.addHeader(HttpHeaders.AUTHORIZATION, value);
|
||||
}
|
||||
// todo 处理请求内容 body 暂不支持body
|
||||
|
||||
// 请求内容,会覆盖post协议的params
|
||||
if(StringUtils.hasLength(httpProtocol.getPayload())){
|
||||
requestBuilder.setEntity(new StringEntity(httpProtocol.getPayload(),"UTF-8"));
|
||||
}
|
||||
|
||||
// uri
|
||||
if (IpDomainUtil.isHasSchema(httpProtocol.getHost())) {
|
||||
|
||||
@@ -45,6 +45,11 @@ public class HttpProtocol {
|
||||
* http请求携带查询参数 eg: localhost:80/api?paramKey=value
|
||||
*/
|
||||
private Map<String, String> params;
|
||||
/**
|
||||
* http请求携带的请求体
|
||||
*/
|
||||
private String payload;
|
||||
|
||||
/**
|
||||
* 认证信息
|
||||
*/
|
||||
|
||||
@@ -169,6 +169,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
param.setType(CommonConstants.PARAM_TYPE_NUMBER);
|
||||
break;
|
||||
case "textarea":
|
||||
case "text":
|
||||
Short limit = paramDefine.getLimit();
|
||||
if (limit != null) {
|
||||
|
||||
@@ -20,6 +20,10 @@ configmap:
|
||||
type: 1
|
||||
- key: password
|
||||
type: 2
|
||||
- key: contentType
|
||||
type: 1
|
||||
- key: payload
|
||||
type: 1
|
||||
# 指标组列表
|
||||
metrics:
|
||||
# 第一个监控指标组 cpu
|
||||
@@ -48,6 +52,10 @@ metrics:
|
||||
method: ^_^method^_^
|
||||
# 是否启用ssl/tls,即是http还是https,默认false
|
||||
ssl: ^_^ssl^_^
|
||||
payload: ^_^payload^_^
|
||||
# 请求头内容
|
||||
headers:
|
||||
content-type: ^_^contentType^_^
|
||||
# 认证
|
||||
authorization:
|
||||
# 认证方式: Basic Auth, Digest Auth, Bearer Token
|
||||
|
||||
@@ -16,6 +16,7 @@ param:
|
||||
# 当type为number时,用range表示范围
|
||||
range: '[0,65535]'
|
||||
required: true
|
||||
defaultValue: 80
|
||||
- field: uri
|
||||
name: 相对路径
|
||||
type: text
|
||||
@@ -37,6 +38,11 @@ param:
|
||||
value: PUT
|
||||
- label: DELETE请求
|
||||
value: DELETE
|
||||
- field: ssl
|
||||
name: 启用HTTPS
|
||||
# 当type为boolean时,前端用switch展示开关
|
||||
type: boolean
|
||||
required: true
|
||||
- field: username
|
||||
name: 用户名
|
||||
type: text
|
||||
@@ -47,8 +53,13 @@ param:
|
||||
name: 密码
|
||||
type: password
|
||||
required: false
|
||||
- field: ssl
|
||||
name: 启用HTTPS
|
||||
# 当type为boolean时,前端用switch展示开关
|
||||
type: boolean
|
||||
required: true
|
||||
- field: contentType
|
||||
name: Content-Type
|
||||
type: text
|
||||
placeholder: '请求BODY资源类型'
|
||||
required: false
|
||||
- field: payload
|
||||
name: 请求BODY
|
||||
type: textarea
|
||||
placeholder: 'POST PUT请求时有效'
|
||||
required: false
|
||||
|
||||
@@ -63,6 +63,30 @@
|
||||
/>
|
||||
</nz-form-control>
|
||||
|
||||
|
||||
<nz-form-label
|
||||
*ngIf="paramDefine.type === 'textarea'"
|
||||
nzSpan="7"
|
||||
[nzRequired]="paramDefine.required"
|
||||
[nzFor]="paramDefine.field"
|
||||
>{{ paramDefine.name }}
|
||||
</nz-form-label>
|
||||
<nz-form-control
|
||||
*ngIf="paramDefine.type === 'textarea'"
|
||||
nzSpan="8"
|
||||
[nzErrorTip]="'validation.required' | i18n"
|
||||
>
|
||||
<textarea
|
||||
nz-input
|
||||
[(ngModel)]="params[i].value"
|
||||
[required]="paramDefine.required"
|
||||
[name]="paramDefine.field"
|
||||
[id]="paramDefine.field"
|
||||
[placeholder]="paramDefine.placeholder ? paramDefine.placeholder : ''"
|
||||
rows="3"
|
||||
></textarea>
|
||||
</nz-form-control>
|
||||
|
||||
<nz-form-label *ngIf="paramDefine.type === 'password'" nzSpan="7" [nzRequired]="paramDefine.required" [nzFor]="paramDefine.field"
|
||||
>{{ paramDefine.name }}
|
||||
</nz-form-label>
|
||||
|
||||
@@ -72,6 +72,29 @@
|
||||
/>
|
||||
</nz-form-control>
|
||||
|
||||
<nz-form-label
|
||||
*ngIf="paramDefine.type === 'textarea'"
|
||||
nzSpan="7"
|
||||
[nzRequired]="paramDefine.required"
|
||||
[nzFor]="paramDefine.field"
|
||||
>{{ paramDefine.name }}
|
||||
</nz-form-label>
|
||||
<nz-form-control
|
||||
*ngIf="paramDefine.type === 'textarea'"
|
||||
nzSpan="8"
|
||||
[nzErrorTip]="'validation.required' | i18n"
|
||||
>
|
||||
<textarea
|
||||
nz-input
|
||||
[(ngModel)]="params[i].value"
|
||||
[required]="paramDefine.required"
|
||||
[name]="paramDefine.field"
|
||||
[id]="paramDefine.field"
|
||||
[placeholder]="paramDefine.placeholder ? paramDefine.placeholder : ''"
|
||||
rows="3"
|
||||
></textarea>
|
||||
</nz-form-control>
|
||||
|
||||
<nz-form-label *ngIf="paramDefine.type === 'password'" nzSpan="7" [nzRequired]="paramDefine.required" [nzFor]="paramDefine.field"
|
||||
>{{ paramDefine.name }}
|
||||
</nz-form-label>
|
||||
|
||||
Reference in New Issue
Block a user