All Projects → spring-cloud-samples → Sample Zuul Filters

spring-cloud-samples / Sample Zuul Filters

Licence: apache-2.0
Samples of custom Zuul 1 filters for use in Spring Cloud Netflix

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Sample Zuul Filters

Spring Cloud Microservices Development
Spring Cloud Microservices Development.《Spring Cloud 微服务架构开发实战》
Stars: ✭ 106 (-47.26%)
Mutual labels:  spring-boot, spring, spring-cloud, zuul, spring-cloud-netflix
Spring Cloud Gateway
A Gateway built on Spring Framework 5.x and Spring Boot 2.x providing routing and more.
Stars: ✭ 3,305 (+1544.28%)
Mutual labels:  api-gateway, spring-boot, spring, spring-cloud
Java Spring Cloud
Distributed tracing for Spring Boot, Cloud and other Spring projects
Stars: ✭ 326 (+62.19%)
Mutual labels:  spring-boot, spring, spring-cloud, zuul
Shop
spring cloud最佳实践项目实例,使用了spring cloud全家桶,TCC事务管理,EDA事务最终一致性等技术的下单示例
Stars: ✭ 418 (+107.96%)
Mutual labels:  api-gateway, spring-boot, spring-cloud, zuul
Sample Spring Microservices Advanced
More advanced samples of spring boot and spring cloud microservices showing usage of such tools like api Swagger2 on Zuul, integraction with MongoDB, configuration server, testing with Spring Cloud Contract or Hoverfly
Stars: ✭ 112 (-44.28%)
Mutual labels:  api-gateway, spring-boot, spring-cloud, zuul
Springcloudlearning
《史上最简单的Spring Cloud教程源码》
Stars: ✭ 16,218 (+7968.66%)
Mutual labels:  spring-boot, spring, spring-cloud, zuul
Sample Spring Microservices
Many samples in different branches that shows how to create microservices with Spring Boot, Spring Cloud, Zipkin, Zuul, Eureka, Hystrix, Kubernetes, Elastic Stack and many more tools
Stars: ✭ 368 (+83.08%)
Mutual labels:  spring-boot, spring-cloud, zuul, spring-cloud-netflix
Spring Cloud Security
Security concerns for distributed applications implemented in Spring
Stars: ✭ 488 (+142.79%)
Mutual labels:  spring-boot, spring, spring-cloud, zuul
Chaos Monkey Spring Boot
Chaos Monkey for Spring Boot
Stars: ✭ 646 (+221.39%)
Mutual labels:  spring-boot, spring, spring-cloud, spring-cloud-netflix
Spring Cloud Examples
Examples of microservice instrastructures
Stars: ✭ 11 (-94.53%)
Mutual labels:  spring-boot, spring, spring-cloud, zuul
Spring Thrift Api Gateway
Gateway for Apache Thrift requests processing that is built on Spring Cloud stack
Stars: ✭ 38 (-81.09%)
Mutual labels:  api-gateway, spring-boot, spring, spring-cloud
Mini Platform
Mini-Platform致力于更简洁易用的轻量级微服务治理平台。
Stars: ✭ 45 (-77.61%)
Mutual labels:  spring-boot, spring, spring-cloud, zuul
Spring Samples
A series of examples used to demonstrate certain features of Spring.
Stars: ✭ 154 (-23.38%)
Mutual labels:  spring-boot, spring, spring-cloud, spring-cloud-netflix
Spring Cloud Flycloud
🔥🔥🔥FlyClould 微服务实战项目框架,在该框架中,包括了用 Spring Cloud 构建微服务的一系列基本组件和框架,对于后台服务框架的搭建有很大的参考价值,大家可以参考甚至稍加修改可以直接应用于自己的实际的项目开发中,该项目没有采用Maven进行项目构建,Maven通过xml进行依赖管理,导致整个配置文件太过臃肿,另外灵活性也不是很强,所以我采用Gradle进行项目构建和依赖管理,在FlyTour项目中我们见证了Gradle的强大,通过简单的一些配置就可以轻松的实现组件化的功能。该项目共有11个Module工程。其中10个位微服务工程,这10个微服务工程构成了一个完整的微服务系统,微服务系统包含了8个基础服务,提供了一整套微服务治理功能,他们分别是配置中心module_c…
Stars: ✭ 1,514 (+653.23%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Cloud Tutorial
Spring Cloud Tutorial.《Spring Cloud 教程》
Stars: ✭ 173 (-13.93%)
Mutual labels:  spring-boot, spring, spring-cloud
Stock Price Viewer Microservices Part1
Spring Cloud services with 5 microservices - End to End Example
Stars: ✭ 115 (-42.79%)
Mutual labels:  spring-boot, spring-cloud, spring-cloud-netflix
Spring Cloud Example
Stars: ✭ 111 (-44.78%)
Mutual labels:  spring-boot, spring, spring-cloud
Spring Cloud Build
Common build concerns, shared plugin configuration, etc. for Spring Cloud modules
Stars: ✭ 114 (-43.28%)
Mutual labels:  spring-boot, spring, spring-cloud
Sample Spring Microservices Kubernetes
sample spring boot application that uses some features provided by spring cloud kubernetes, spring cloud ribbon and zuul proxy deployed on Kubernetes
Stars: ✭ 123 (-38.81%)
Mutual labels:  spring-boot, spring-cloud, zuul
Spring Cloud Config
External configuration (server and client) for Spring Cloud
Stars: ✭ 1,740 (+765.67%)
Mutual labels:  spring-boot, spring, spring-cloud

Sample Zuul Filters

Run the 3 application classes as spring boot applications.

  • ZuulGatewayApplication: runs zuul on port 8080
  • FooApplication: hosts a /foo service on port 9080
  • BarApplication: hosts a /foo service with a different implementation on port 7080

There are a number of filters are implemented:

  • AddResponseHeaderFilter: adds a random X-Foo header to the response
  • ModifyResponseBodyFilter: Adds a prefix to the response using RequestContext.setResponseBody(String). Only runs if service query parameter is NOT set.
  • ModifyResponseDataStreamFilter: Adds a prefix to the response using RequestContext.setResponseDataStream(InputStream). Only runs if service query parameter is set.
  • PrefixRequestEntityFilter: Adds a prefix to the request body by using a request wrapper and RequestContext.setRequest(). Only runs if service query parameter is set.
  • QueryParamPortPreFilter: sets the port of the RequestContext.getRouteHost to the value of the port query parameter. Only runs if port query parameter is set.
  • QueryParamServiceIdPreFilter: sets the serviceId to the value of the service query parameter.
  • UppercaseRequestEntityFilter: Upper cases the request body by setting RequestContext.setRequest("requestEntity"). Only runs if service query parameter is NOT set.

Examples

All examples use HTTPie(A better curl replacement).

$ http :8080/foo 
HTTP/1.1 200 
Content-Type: text/plain;charset=UTF-8
Date: Wed, 22 Mar 2017 20:06:45 GMT
Transfer-Encoding: chunked
X-Application-Context: application
X-Foo: 41e04412-84e8-48ac-8d71-cec209eda9ca

Modified via setResponseBody(): foo from FooApplication$$EnhancerBySpringCGLIB$$82229332

The application is routed to FooApplication because the response contains foo from FooApplication.

The AddResponseHeaderFilter ran because of the X-Foo: 41e04412-84e8-48ac-8d71-cec209eda9ca header was added to the response.

The ModifyResponseBodyFilter was run because the body was prefixed with Modified via setResponseBody():.

$ http ":8080/foo?service=bar"
HTTP/1.1 200 
Content-Type: text/plain;charset=UTF-8
Date: Wed, 22 Mar 2017 20:09:23 GMT
Transfer-Encoding: chunked
X-Application-Context: application
X-Foo: 9dc2e5fa-a43f-445d-a289-d3e62319413a

Modified via setResponseDataStream(): bar from BarApplication$$EnhancerBySpringCGLIB$$a78c1598

The application is routed to BarApplication because the response contains bar from BarApplication.

The AddResponseHeaderFilter ran because of the X-Foo: 9dc2e5fa-a43f-445d-a289-d3e62319413a header was added to the response.

The ModifyResponseDataStreamFilter was run because the body was prefixed with Modified via setResponseDataStream():.

$ echo -n "hello" | http POST :8080/foo
HTTP/1.1 200 
Content-Type: application/json;charset=UTF-8
Date: Wed, 22 Mar 2017 21:48:46 GMT
Transfer-Encoding: chunked
X-Application-Context: application
X-Foo: 69866ea1-db9a-4275-a8f1-5e20d87e5065

Modified via setResponseBody(): foo recieved: HELLO

UppercaseRequestEntityFilter was run because foo recieved: HELLO was in the response body.

$ echo -n "hello" | http POST ":8080/foo?service=bar"
HTTP/1.1 200 
Content-Type: application/json;charset=UTF-8
Date: Wed, 22 Mar 2017 21:49:02 GMT
Transfer-Encoding: chunked
X-Application-Context: application
X-Foo: 97aebe27-6845-4dc3-9ef6-80ccdf14059d

Modified via setResponseDataStream(): bar recieved: request body modified via request wrapper: hello

PrefixRequestEntityFilter was run because foo recieved: HELLO was in the response body.

$ http :8080/hello
HTTP/1.1 500 
Connection: close
Content-Type: application/json;charset=UTF-8
Date: Fri, 24 Mar 2017 21:05:04 GMT
Transfer-Encoding: chunked
X-Application-Context: application

{
    "error": "Internal Server Error",
    "exception": "org.apache.http.conn.HttpHostConnectException",
    "message": "Connect to localhost:80 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1, localhost/fe80:0:0:0:0:0:0:1%1] failed: Connection refused",
    "status": 500,
    "timestamp": 1490389504014
}

Uses a bad port, QueryParamPortPreFilter not run.

$ http ":8080/hello?port=9080"
HTTP/1.1 200 
Content-Type: text/plain;charset=UTF-8
Date: Fri, 24 Mar 2017 21:07:07 GMT
Transfer-Encoding: chunked
X-Application-Context: application
X-Foo: 50774952-b947-47cd-902b-2889d02feece

Modified via setResponseBody(): hello from FooApplication$$EnhancerBySpringCGLIB$$82229332

QueryParamPortPreFilter was run because response contains hello from FooApplication.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].