/**
* 文件名: MyFilter.java
* 版 权: Copyright © 2013 - 2018 CFNE, Inc. All Rights Reserved
* 描 述: <描述>
* 修改人: HuaSheng.Liu
* 修改时间: 2018/3/9
* 跟踪单号: <跟踪单号>
* 修改单号: <修改单号>
* 修改内容: <修改内容>
*/
package com.cloud.servicezuul.filter;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
/**
* 功能描述 :
* @author HuaSheng.Liu
* @version [版本号, 2018/3/9]
* @see [相关类/方法]
* @since [产品/模板版本号]
*/
@Component
public class MyFilter extends ZuulFilter
{
private static Logger log = LoggerFactory.getLogger(MyFilter.class);
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 0;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
log.info(String.format("%s >>> %s", request.getMethod(), request.getRequestURL().toString()));
Object accessToken = request.getParameter("token");
if(accessToken == null) {
log.warn("token is empty");
ctx.setSendZuulResponse(false);
ctx.setResponseStatusCode(401);
try {
ctx.getResponse().getWriter().write("token is empty");
}catch (Exception e){}
return null;
}
log.info("ok");
return null;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
SpringCloud基于SpringBoot 分布式服务实现
共318个文件
xml:214个
properties:22个
class:21个
需积分: 50 27 下载量 153 浏览量
2018-03-14
10:30:37
上传
评论 2
收藏 571KB ZIP 举报
温馨提示
SpringCloud基于SpringBoot 分布式服务实现,暂时实现了服务发现,rabbin和fegin两种调用方式,负载均衡、只能路由后续会持续更新代码(自己学习分布式服务架构,之前有dubbo开发经验,想去学习Spring全家桶)
资源推荐
资源详情
资源评论
收起资源包目录
SpringCloud基于SpringBoot 分布式服务实现 (318个子文件)
MyFilter.class 2KB
EurekaClient1Application.class 2KB
EurekaClientApplication.class 2KB
ServiceRibbonApplication.class 1KB
HelloService.class 1KB
HiController.class 1KB
SericeFeignApplication.class 1019B
HelloControler.class 1000B
ServiceZuulApplication.class 865B
SchedualServiceHiHystric.class 833B
EurekaServer1Application.class 821B
EurekaServerApplication.class 816B
RibbonConfiguration.class 778B
SchedualServiceHi.class 697B
ServiceRibbonApplicationTests.class 665B
EurekaServer1ApplicationTests.class 665B
EurekaClient1ApplicationTests.class 665B
EurekaServerApplicationTests.class 660B
EurekaClientApplicationTests.class 660B
SericeFeignApplicationTests.class 655B
ServiceZuulApplicationTests.class 653B
mvnw.cmd 5KB
mvnw.cmd 5KB
mvnw.cmd 5KB
mvnw.cmd 5KB
mvnw.cmd 5KB
mvnw.cmd 5KB
mvnw.cmd 5KB
mvnw.cmd 5KB
.gitignore 249B
.gitignore 249B
.gitignore 249B
.gitignore 249B
.gitignore 249B
.gitignore 249B
.gitignore 249B
.gitignore 249B
spring.iml 22KB
serice_feign.iml 18KB
service-zuul.iml 18KB
service_ribbon.iml 17KB
eureka_server.iml 17KB
eureka_server1.iml 17KB
eureka_client.iml 16KB
eureka_client1.iml 16KB
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
MyFilter.java 2KB
HiController.java 1KB
HelloService.java 1KB
HelloControler.java 1KB
SchedualServiceHi.java 1KB
RibbonConfiguration.java 969B
ServiceRibbonApplication.java 951B
EurekaClient1Application.java 843B
EurekaClientApplication.java 841B
SchedualServiceHiHystric.java 770B
SericeFeignApplication.java 689B
ServiceZuulApplication.java 491B
EurekaServer1Application.java 425B
EurekaServerApplication.java 422B
ServiceRibbonApplicationTests.java 348B
EurekaServer1ApplicationTests.java 348B
EurekaClient1ApplicationTests.java 348B
EurekaServerApplicationTests.java 346B
EurekaClientApplicationTests.java 346B
SericeFeignApplicationTests.java 344B
ServiceZuulApplicationTests.java 343B
mvnw 6KB
mvnw 6KB
mvnw 6KB
mvnw 6KB
mvnw 6KB
mvnw 6KB
mvnw 6KB
mvnw 6KB
application.properties 1KB
application.properties 1KB
application.properties 293B
application.properties 293B
application.properties 231B
application.properties 231B
application.properties 230B
application.properties 230B
application.properties 155B
application.properties 155B
application.properties 151B
application.properties 151B
application.properties 151B
application.properties 151B
maven-wrapper.properties 110B
maven-wrapper.properties 110B
maven-wrapper.properties 110B
maven-wrapper.properties 110B
共 318 条
- 1
- 2
- 3
- 4
资源评论
lhs12344
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功