Skip to content

Commit

Permalink
feat: api规则细节限制优化
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtsm committed Apr 22, 2023
1 parent e5a923e commit c70316f
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align=center><img src="doc/logo.png"/></div>

[![](https://img.shields.io/badge/base-openresty-blue?style=flat-square)](https://openresty.org/cn/) ![Build](https://img.shields.io/badge/build-passing-green?style=flat-square) ![Version](https://img.shields.io/github/v/tag/iamtsm/tl-ops-manage?color=green&label=Version&style=flat-square) ![License](https://img.shields.io/badge/License-Apache%202.0-blue?style=flat-square)
[![](https://img.shields.io/badge/base-openresty-blue?style=flat-square)](https://openresty.org/cn/) ![Build](https://img.shields.io/badge/build-passing-green?style=flat-square) ![Version](https://img.shields.io/github/v/tag/iamtsm/tl-ops-manage?color=green&label=Version&style=flat-square)

基于openresty的API网关,支持负载均衡,健康检查,服务熔断,服务限流,waf过滤,黑白名单,动态SSL证书,自定义插件,多级缓存,可视化管理,动态配置,动态插拔插件,数据统计,数据展示,集群部署

Expand Down
2 changes: 1 addition & 1 deletion balance/tl_ops_balance_core_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ local tl_ops_balance_api_service_matcher = function(service_list_table)
ngx.var.tlops_ups_api_prefix = fake_sub
end
end

return node, node_state, node_id, host, rule_match_mode
end

Expand Down
2 changes: 1 addition & 1 deletion bin/install_centeros.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ TL_OPS_PATH="/usr/local/tl-ops-manage/"
TL_OPS_CONF_PATH="/usr/local/tl-ops-manage/conf/tl_ops_manage.conf"
TL_OPS_LUA_PATH="/usr/local/openresty/lualib/?.lua;;/usr/local/tl-ops-manage/?.lua;;"
TL_OPS_LUAC_PATH="/usr/local/openresty/lualib/?.so;;"
TL_OPS_VER="v3.4.4"
TL_OPS_VER="v3.4.5"

echo_msg(){
cur_time=$(date "+%Y-%m-%d %H:%M:%S")
Expand Down
2 changes: 1 addition & 1 deletion bin/install_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ TL_OPS_PATH="/usr/local/tl-ops-manage/"
TL_OPS_CONF_PATH="/usr/local/tl-ops-manage/conf/tl_ops_manage.conf"
TL_OPS_LUA_PATH="/usr/local/openresty/lualib/?.lua;;/usr/local/tl-ops-manage/?.lua;;"
TL_OPS_LUAC_PATH="/usr/local/openresty/lualib/?.so;;"
TL_OPS_VER="v3.4.4"
TL_OPS_VER="v3.4.5"

echo_msg(){
cur_time=$(date "+%Y-%m-%d %H:%M:%S")
Expand Down
7 changes: 7 additions & 0 deletions doc/change.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

## 事务更新日程

2023-04-22

1. api规则细节限制优化

2. 事务日程调整


2023-03-26

1. 补充部分测试用例
Expand Down
81 changes: 63 additions & 18 deletions web/balance/tl_ops_web_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,38 @@ const tl_ops_api_data_add_filter = function( data ) {
if(rule === 'random'){
delete data.field.node
}
for(let key in data.field){
if(key === 'id' || key === 'rewrite_url' || key === 'fake_prefix'){
continue;
}
if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){
layer.msg(key + "未填写")
return false;

let api_type = data.field.api_type;

if(api_type === 'page'){
for(let key in data.field){
if(key === 'id' || key === 'rewrite_url' || key === 'fake_prefix' || key === 'service' || key === 'node'){
continue;
}

if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){
layer.msg(key + "未填写")
return false;
}
if(key === 'node'){
data.field[key] = parseInt(data.field[key])
}
}
if(key === 'node'){
data.field[key] = parseInt(data.field[key])
}

if(api_type === 'api'){
for(let key in data.field){
if(key === 'id' || key === 'rewrite_url' || key === 'fake_prefix'){
continue;
}

if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){
layer.msg(key + "未填写")
return false;
}
if(key === 'node'){
data.field[key] = parseInt(data.field[key])
}
}
}

Expand All @@ -402,18 +424,41 @@ const tl_ops_api_data_edit_filter = function( data ) {
if(rule === 'random'){
delete data.field.node
}
for(let key in data.field){
if(key === 'rewrite_url' || key === 'fake_prefix'){
continue
}
if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){
layer.msg(key + "未填写")
return false;

let api_type = data.field.api_type;

if(api_type === 'page'){
for(let key in data.field){
if(key === 'rewrite_url' || key === 'fake_prefix' || key === 'service' || key === 'node'){
continue;
}

if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){
layer.msg(key + "未填写")
return false;
}
if(key === 'node'){
data.field[key] = parseInt(data.field[key])
}
}
if(key === 'node'){
data.field[key] = parseInt(data.field[key])
}

if(api_type === 'api'){
for(let key in data.field){
if(key === 'rewrite_url' || key === 'fake_prefix'){
continue;
}

if(data.field[key] === undefined || data.field[key] === null || data.field[key] === ''){
layer.msg(key + "未填写")
return false;
}
if(key === 'node'){
data.field[key] = parseInt(data.field[key])
}
}
}

let cur_list = []
res_data.tl_ops_balance_api_list[rule].forEach((item)=>{
if(parseInt(item.id) === parseInt(data.field.id)){
Expand Down
19 changes: 19 additions & 0 deletions web/balance/tl_ops_web_api_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ const tl_ops_web_api_form_main = async function (){
}
});

form.on('radio', function(data){
if(data.value === 'page'){
document.getElementById("tl-ops-web-api-form-service-view").style.display = "none";
document.getElementById("tl-ops-web-api-form-service-node-view").style.display = "none";
}else if(data.value === 'api'){
document.getElementById("tl-ops-web-api-form-service-view").style.display = "block";
document.getElementById("tl-ops-web-api-form-service-node-view").style.display = "block";
}
});

let res = await axios.get("/tlops/service/list");
res = res.data;
if(res.code === 0){
Expand Down Expand Up @@ -61,6 +71,15 @@ const tl_ops_web_api_form_main = async function (){


window.tl_ops_web_api_form_render = function(data){
if(data){
if(data.api_type === 'page'){
document.getElementById("tl-ops-web-api-form-service-view").style.display = "none";
document.getElementById("tl-ops-web-api-form-service-node-view").style.display = "none";
}else if(data.api_type === 'api'){
document.getElementById("tl-ops-web-api-form-service-view").style.display = "block";
document.getElementById("tl-ops-web-api-form-service-node-view").style.display = "block";
}
}
form.val("tl-ops-web-api-form", Object.assign(form.val("tl-ops-web-api-form"), data))
form.render()
document.querySelector("#fake_prefix").dispatchEvent(new Event('input', {}))
Expand Down

0 comments on commit c70316f

Please sign in to comment.