0
点赞
收藏
分享

微信扫一扫

公有云攻击案例

犹大之窗 2023-10-18 阅读 39

一、定义controller

package cn.edu.tju.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HotParamController {
    @RequestMapping("/getHotParam/{id}")
    @SentinelResource(value = "getHotParam", blockHandler = "myBlockHandler")
    public String getHotParam(@PathVariable String id){
        return "get: " + id;
    }

    public String myBlockHandler(@PathVariable String id, BlockException ex){
        return "get: 热点数据";
    }
}

二、配置热点参数限制规则
在这里插入图片描述
然后编辑规则:
在这里插入图片描述

举报

相关推荐

0 条评论