Skip to content

Commit 823b3fe

Browse files
author
nkushnir
committed
add micro-proxy zuul gateway
1 parent ee18384 commit 823b3fe

File tree

9 files changed

+145
-1
lines changed

9 files changed

+145
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Sandbox to play with spring cloud features
1616
| Hackster service| Hackster Detection Service | 8082| |
1717
| Realtor service| Realtor Api Service | 8080| To call other services used Feign, RestTemplate |
1818
| Storage service| Storage of Apartment Records Service | 8091| H2 based service for ApartmentRecord data storage. |
19+
| API gateway service| Zull API Gateway Service | 8090| |
1920

2021

2122
# Dev
@@ -41,7 +42,7 @@ If no then add it using this : `export DOCKER_HOST=unix:///var/run/docker.sock`
4142
- [x] Rieltor Service
4243
- [x] All eurika clients add eurika server address to properties
4344
- [ ] Client service for search
44-
- [ ] Zuul like a proxy API gateway
45+
- [x] Zuul like a proxy API gateway
4546
- [ ] Cloud foundary
4647
- [x] FeignClient usage
4748
- [ ] Circuit Breaker: Hystrix Clients

api-gateway-service/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
4+
### STS ###
5+
.apt_generated
6+
.classpath
7+
.factorypath
8+
.project
9+
.settings
10+
.springBeans
11+
12+
### IntelliJ IDEA ###
13+
.idea
14+
*.iws
15+
*.iml
16+
*.ipr
17+
18+
### NetBeans ###
19+
nbproject/private/
20+
build/
21+
nbbuild/
22+
dist/
23+
nbdist/
24+
.nb-gradle/

api-gateway-service/pom.xml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.lohika.jclub.gateway</groupId>
7+
<artifactId>api-gateway-service</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>API gateway service</name>
12+
<description>Zuul API Gateway service</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.5.4.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
<java.version>1.8</java.version>
25+
<spring-cloud.version>Dalston.SR1</spring-cloud.version>
26+
</properties>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.springframework.cloud</groupId>
31+
<artifactId>spring-cloud-starter-zuul</artifactId>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>org.springframework.cloud</groupId>
36+
<artifactId>spring-cloud-starter-eureka</artifactId>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter-test</artifactId>
42+
<scope>test</scope>
43+
</dependency>
44+
</dependencies>
45+
46+
<dependencyManagement>
47+
<dependencies>
48+
<dependency>
49+
<groupId>org.springframework.cloud</groupId>
50+
<artifactId>spring-cloud-dependencies</artifactId>
51+
<version>${spring-cloud.version}</version>
52+
<type>pom</type>
53+
<scope>import</scope>
54+
</dependency>
55+
</dependencies>
56+
</dependencyManagement>
57+
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-maven-plugin</artifactId>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
67+
68+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.lohika.jclub;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6+
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
7+
8+
@EnableZuulProxy
9+
@SpringBootApplication
10+
@EnableDiscoveryClient
11+
public class ApiGatewayServiceApplication {
12+
13+
public static void main(String[] args) {
14+
SpringApplication.run(ApiGatewayServiceApplication.class, args);
15+
}
16+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
spring.application.name=api-gateway-service
2+
server.port=8090
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
zuul:
2+
prefix: /api
3+
4+
routes:
5+
realtor:
6+
path: /realtor-service/**
7+
serviceId: realtor-service
8+
9+
ignored-services: '*'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
___ _ __ _
2+
/ | ____ (_) ____ _____ _/ /____ _ ______ ___ __ ________ ______ __(_)_______
3+
/ /| | / __ \/ /_____/ __ `/ __ `/ __/ _ \ | /| / / __ `/ / / / / ___/ _ \/ ___/ | / / / ___/ _ \
4+
/ ___ |/ /_/ / /_____/ /_/ / /_/ / /_/ __/ |/ |/ / /_/ / /_/ / (__ ) __/ / | |/ / / /__/ __/
5+
/_/ |_/ .___/_/ \__, /\__,_/\__/\___/|__/|__/\__,_/\__, / /____/\___/_/ |___/_/\___/\___/
6+
/_/ /____/ /____/
7+
v.${application.version}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.lohika.jclub;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class ApiGatewayServiceApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<module>realtor-service</module>
2020
<module>storage-service</module>
2121
<module>storage-service-client</module>
22+
<module>api-gateway-service</module>
2223
</modules>
2324
</project>

0 commit comments

Comments
 (0)