• Stars
    star
    360
  • Rank 118,230 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sample Spring Cloud Gateway Application

Spring Cloud Gateway Sample

Sample that shows a few different ways to route and showcases some filters.

Run DemogatewayApplication

Samples

$ http :8080/get
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Length: 257
Content-Type: application/json
Date: Fri, 13 Oct 2017 15:36:12 GMT
Expires: 0
Pragma: no-cache
Server: meinheld/0.6.1
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Powered-By: Flask
X-Processed-Time: 0.00123405456543
X-XSS-Protection: 1 ; mode=block

{
    "args": {}, 
    "headers": {
        "Accept": "*/*", 
        "Accept-Encoding": "gzip, deflate", 
        "Connection": "close", 
        "Host": "httpbin.org", 
        "User-Agent": "HTTPie/0.9.8"
    }, 
    "origin": "207.107.158.66", 
    "url": "http://httpbin.org/get"
}


$ http :8080/headers Host:www.myhost.org
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Length: 175
Content-Type: application/json
Date: Fri, 13 Oct 2017 15:36:35 GMT
Expires: 0
Pragma: no-cache
Server: meinheld/0.6.1
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Powered-By: Flask
X-Processed-Time: 0.0012538433075
X-XSS-Protection: 1 ; mode=block

{
    "headers": {
        "Accept": "*/*", 
        "Accept-Encoding": "gzip, deflate", 
        "Connection": "close", 
        "Host": "httpbin.org", 
        "User-Agent": "HTTPie/0.9.8"
    }
}

$ http :8080/foo/get Host:www.rewrite.org
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: keep-alive
Content-Length: 257
Content-Type: application/json
Date: Fri, 13 Oct 2017 15:36:51 GMT
Expires: 0
Pragma: no-cache
Server: meinheld/0.6.1
Via: 1.1 vegur
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Powered-By: Flask
X-Processed-Time: 0.000664949417114
X-XSS-Protection: 1 ; mode=block

{
    "args": {}, 
    "headers": {
        "Accept": "*/*", 
        "Accept-Encoding": "gzip, deflate", 
        "Connection": "close", 
        "Host": "httpbin.org", 
        "User-Agent": "HTTPie/0.9.8"
    }, 
    "origin": "207.107.158.66", 
    "url": "http://httpbin.org/get"
}

$ http :8080/delay/2 Host:www.circuitbreaker.org
HTTP/1.1 504 Gateway Timeout
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Expires: 0
Pragma: no-cache
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1 ; mode=block
content-length: 0


Websocket Sample

install wscat

In one terminal, run websocket server:

wscat --listen 9000

In another, run a client, connecting through gateway:

wscat --connect ws://localhost:8080/echo

type away in either server and client, messages will be passed appropriately.

Running Redis Rate Limiter Test

Make sure redis is running on localhost:6379 (using brew or apt or docker).

Then run DemogatewayApplicationTests. It should pass which means one of the calls received a 429 TO_MANY_REQUESTS HTTP status.

More Repositories

1

eureka

Java
500
star
2

customers-stores

Two microservices for customers and stores
Java
431
star
3

spring-cloud-contract-samples

Samples for Spring Cloud Contract project
Java
379
star
4

configserver

Java
371
star
5

brewery

Brewing beer with Spring Cloud has never been that easy...
Java
353
star
6

feign-eureka

Example of using feign with eureka
Java
236
star
7

config-repo

Configuration files for the server sample
138
star
8

bookstore-service-broker

Sample application for Spring Cloud Open Service Broker
Java
72
star
9

spring-cloud-circuitbreaker-demo

Samples demonstrating how to using Spring Cloud Circuitbreaker
Java
64
star
10

spring-cloud-sleuth-samples

Contains isolated samples of Spring Cloud Sleuth
Java
23
star
11

spring-cloud-contract-nodejs

Spring Cloud Contract with Node JS application
Shell
22
star
12

spring-cloud-config-vault

Sample application demonstrating how to use Hashicorp Vault as a backend for a Spring Cloud Config server
Java
16
star
13

svn-config-server

Sample Config Server and Config Client. The Config Server is configured to use Subversion rather than git
Java
16
star
14

spring-cloud-app-broker-samples

Sample apps for https://github.com/spring-cloud/spring-cloud-app-broker
Java
8
star
15

spring-cloud-square-retrofit-web

Demo project for Spring Cloud Square Retrofit Web
Java
3
star
16

sleuth-issues

Samples for Sleuth that replicate issues
Java
2
star
17

spring-cloud-function-samples

1
star
18

spring-cloud-square-retrofit-webclient

Java
1
star
19

spring-cloud-intro-demo-config

Centralised Configuration for Spring Cloud Intro Demo
1
star
20

spring-cloud-contract-nodejs-external-contracts

External contracts for the Spring Cloud Contract NodeJS sample
Java
1
star