<init-param> <param-name>cors.supportedHeaders</param-name> <param-value>Accept, Origin, X-Requested-With, Content-Type, Last-Modified</param-value> </init-param> |
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(==防止爬虫==):http://blog.liuyingguang.cn
<servlet> <servlet-name>Rest_Servlet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>cn.firewarm.testRestShiro.rest</param-value> </init-param> <init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>cn.firewarm.testRestShiro.filter.TestFilter</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> |
public class TestFilter implements ContainerRequestFilter { public ContainerRequest filter(ContainerRequest request) { if(判断条件){ return request; }else{ Response response = Response.ok("error").status(401).type(MediaType.APPLICATION_JSON).build(); throw new WebApplicationException(response); // Throw new UnAuthor |
材料:
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(==防止爬虫==):http://blog.liuyingguang.cn
环境介绍:
<build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.version}</version> <configuration> <systemProperties> </systemProperties> <webApp> <contextPath>/</contextPath> </webApp> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </pl
最近在做微服务相关产品,其中需要有API网关相关产品,虽然早有研究过API网关产品TYK,但是感觉其太重,想起之前研究开源BI产品saiku的时候,记得其有NodeJS的代理代码,于是看了下,颇有启发,略微修改了一些,拿出来跟大家分享下,虽然简单,不可用于生产,但是对于学习还是不错的
{
"name": "SmartHttpProxy",
"description": "An simplest Http Proxy",
"version": "0.0.1",
"author": "liuyg@liuyingguang.cn",
"license": {
"type": "Apache License Version 2"
},
"main": "server.js",
"scripts": {
"start": "node server.js 8088 127.0.0.1 80 / "
},
"dependencies": {
"express": "~4.13.4"
}
}
/*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either e