feat: auto add http protocol head

This commit is contained in:
KFCFans 2020-11-14 13:58:40 +08:00
parent c9b0cef1ea
commit 8bb2cd7f3f
2 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,9 @@ import java.util.List;
@Service
public class WebHookAlarmService implements Alarmable {
private static final String HTTP_PROTOCOL_PREFIX = "http://";
private static final String HTTPS_PROTOCOL_PREFIX = "https://";
@Override
public void onFailed(Alarm alarm, List<UserInfoDO> targetUserList) {
if (CollectionUtils.isEmpty(targetUserList)) {
@ -36,6 +39,11 @@ public class WebHookAlarmService implements Alarmable {
return;
}
// 自动添加协议头
if (!webHook.startsWith(HTTP_PROTOCOL_PREFIX) && !webHook.startsWith(HTTPS_PROTOCOL_PREFIX)) {
webHook = HTTP_PROTOCOL_PREFIX + webHook;
}
MediaType jsonType = MediaType.parse(OmsConstant.JSON_MEDIA_TYPE);
RequestBody requestBody = RequestBody.create(jsonType, JSONObject.toJSONString(alarm));

View File

@ -15,6 +15,7 @@ public class ModifyUserInfoRequest {
private String username;
private String password;
private String webHook;
// 手机号
private String phone;