Compare commits
7 commits
45f52ab941
...
09a253f3cc
Author | SHA1 | Date | |
---|---|---|---|
hirst | 09a253f3cc | ||
hirst | 31dcb2abf5 | ||
hirst | a36c9d778b | ||
hirst | 035eb6ffb2 | ||
hirst | a651681c67 | ||
hirst | c02b24e766 | ||
hirst | 8e3bba298f |
|
@ -4,5 +4,7 @@
|
||||||
<file url="file://$PROJECT_DIR$/dummy/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/dummy/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/eureka/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/eureka/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/gateway/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/gateway/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -8,6 +8,7 @@
|
||||||
<option value="$PROJECT_DIR$/eurika/pom.xml" />
|
<option value="$PROJECT_DIR$/eurika/pom.xml" />
|
||||||
<option value="$PROJECT_DIR$/gateway/pom.xml" />
|
<option value="$PROJECT_DIR$/gateway/pom.xml" />
|
||||||
<option value="$PROJECT_DIR$/eureka/pom.xml" />
|
<option value="$PROJECT_DIR$/eureka/pom.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/server.iml" filepath="$PROJECT_DIR$/.idea/server.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -3,20 +3,56 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>3.2.5</version>
|
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
|
||||||
<groupId>com.learningpulse</groupId>
|
<groupId>com.learningpulse</groupId>
|
||||||
|
<artifactId>server</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
</parent>
|
||||||
<artifactId>dummy</artifactId>
|
<artifactId>dummy</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1</version>
|
||||||
<name>dummy</name>
|
<name>dummy</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>A dummy project</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>22</java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-config-server</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.springframework.security.oauth/spring-security-oauth2 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security.oauth</groupId>
|
||||||
|
<artifactId>spring-security-oauth2</artifactId>
|
||||||
|
<version>2.5.2.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-oauth2-resource-server</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
@ -27,16 +63,6 @@
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-test</artifactId>
|
<artifactId>spring-security-test</artifactId>
|
||||||
|
@ -44,21 +70,4 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
</exclude>
|
|
||||||
</excludes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -2,8 +2,11 @@ package com.learningpulse.dummy;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class DummyApplication {
|
public class DummyApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
16
dummy/src/main/java/com/learningpulse/dummy/Test.java
Normal file
16
dummy/src/main/java/com/learningpulse/dummy/Test.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package com.learningpulse.dummy;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/dummy")
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
@GetMapping("/test")
|
||||||
|
public ResponseEntity<String> test() {
|
||||||
|
return ResponseEntity.ok("Hello, World!");
|
||||||
|
}
|
||||||
|
}
|
2
dummy/src/main/resources/application-docker.yml
Normal file
2
dummy/src/main/resources/application-docker.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
app:
|
||||||
|
eureka-server: eureka
|
|
@ -1 +0,0 @@
|
||||||
spring.application.name=dummy
|
|
36
dummy/src/main/resources/application.yml
Normal file
36
dummy/src/main/resources/application.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
app:
|
||||||
|
eureka-server: localhost
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 0
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: dummy
|
||||||
|
|
||||||
|
# TODO remove after testing
|
||||||
|
security:
|
||||||
|
user:
|
||||||
|
name: admin
|
||||||
|
password: admin
|
||||||
|
|
||||||
|
springdoc:
|
||||||
|
enable-native-support: true
|
||||||
|
api-docs:
|
||||||
|
enabled: true
|
||||||
|
path: /api/v1/dummy/v3/api-docs
|
||||||
|
swagger-ui:
|
||||||
|
path: /api/v1/dummy/swagger-ui.html
|
||||||
|
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: "*"
|
||||||
|
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
service-url:
|
||||||
|
defaultZone: http://localhost:8761/eureka
|
||||||
|
# Will only work when docker is used
|
||||||
|
# defaultZone: http://${app.eureka-server}:8761/eureka
|
|
@ -3,20 +3,17 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>3.2.5</version>
|
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
|
||||||
</parent>
|
|
||||||
<groupId>com.learningpulse</groupId>
|
<groupId>com.learningpulse</groupId>
|
||||||
|
<artifactId>server</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
</parent>
|
||||||
<artifactId>eureka</artifactId>
|
<artifactId>eureka</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1</version>
|
||||||
<name>eureka</name>
|
<name>eureka</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Eureka discovery server for LearningPulse</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>22</java.version>
|
|
||||||
<spring-cloud.version>2023.0.1</spring-cloud.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server -->
|
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -24,33 +21,6 @@
|
||||||
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
|
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
|
||||||
<version>4.1.1</version>
|
<version>4.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-dependencies</artifactId>
|
|
||||||
<version>${spring-cloud.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.learningpulse.eurika;
|
package com.learningpulse.eureka;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -1,10 +0,0 @@
|
||||||
spring.application.name=eureka
|
|
||||||
|
|
||||||
server.port=8761
|
|
||||||
|
|
||||||
spring.security.user.name=admin
|
|
||||||
spring.security.user.password=admin
|
|
||||||
|
|
||||||
eureka.instance.hostname=localhost
|
|
||||||
eureka.client.register-with-eureka=false
|
|
||||||
eureka.client.fetch-registry=false
|
|
18
eureka/src/main/resources/application.yml
Normal file
18
eureka/src/main/resources/application.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
server:
|
||||||
|
port: 8761
|
||||||
|
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
register-with-eureka: false
|
||||||
|
fetch-registry: false
|
||||||
|
instance:
|
||||||
|
hostname: localhost
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: eureka
|
||||||
|
security:
|
||||||
|
# TODO remove after testing
|
||||||
|
user:
|
||||||
|
name: admin
|
||||||
|
password: admin
|
|
@ -1,4 +1,4 @@
|
||||||
package com.learningpulse.eurika;
|
package com.learningpulse.eureka;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
@ -3,75 +3,49 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.learningpulse</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>server</artifactId>
|
||||||
<version>3.2.5</version>
|
<version>0.0.1</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.learningpulse</groupId>
|
|
||||||
<artifactId>gateway</artifactId>
|
<artifactId>gateway</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1</version>
|
||||||
<name>gateway</name>
|
<name>gateway</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>API gateway for LearningPulse</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>22</java.version>
|
|
||||||
<spring-cloud.version>2023.0.1</spring-cloud.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
<!-- TODO bad dependencies here, CHANGE cus:
|
|
||||||
https://stackoverflow.com/questions/68587832/spring-cloud-gateway-spring-mvc-found-on-classpath-which-is-incompatible-with
|
|
||||||
TLDR: spring-cloud-starter-gateway-mvc is not compatible with eureka server (spring-cloud-starter-gateway)
|
|
||||||
-->
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
<artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-gateway-mvc</artifactId>
|
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.restdocs</groupId>
|
|
||||||
<artifactId>spring-restdocs-mockmvc</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<dependency>
|
||||||
<dependencyManagement>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<dependencies>
|
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-dependencies</artifactId>
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
<version>${spring-cloud.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -100,18 +74,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
</exclude>
|
|
||||||
</excludes>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,11 @@ package com.learningpulse.gateway;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
||||||
|
|
||||||
|
|
||||||
@EnableDiscoveryClient
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableWebFluxSecurity
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class GatewayApplication {
|
public class GatewayApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
package com.learningpulse.gateway;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.web.servlet.function.RouterFunction;
|
|
||||||
import org.springframework.web.servlet.function.ServerResponse;
|
|
||||||
|
|
||||||
import static org.springframework.web.servlet.function.RouterFunctions.route;
|
|
||||||
import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http;
|
|
||||||
|
|
||||||
public class SimpleGateway {
|
|
||||||
@Bean
|
|
||||||
public RouterFunction<ServerResponse> getRoute() {
|
|
||||||
return route().GET("/get", http("https://httpbin.org")).build();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.learningpulse.gateway.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.function.RouterFunction;
|
|
||||||
import org.springframework.web.servlet.function.ServerResponse;
|
|
||||||
|
|
||||||
import org.springframework.web.servlet.function.RouterFunctions;
|
|
||||||
|
|
||||||
|
|
||||||
// TODO copy lambda code lol
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
|
||||||
public class Appconfig {
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.learningpulse.gateway.config;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.info.Contact;
|
||||||
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class OpenAPIConfiguration {
|
||||||
|
@Bean
|
||||||
|
public OpenAPI gatewayOpenAPI() {
|
||||||
|
return new OpenAPI().info(new Info()
|
||||||
|
.title("Learning Pulse API documentation")
|
||||||
|
.version("0.0.1")
|
||||||
|
.description("This is the API documentation for the Learning Pulse project.")
|
||||||
|
.contact(new Contact()
|
||||||
|
.name("Learning Pulse")
|
||||||
|
.url("https://git.4o1x5.dev/LearningPulse"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
2
gateway/src/main/resources/application-docker.yml
Normal file
2
gateway/src/main/resources/application-docker.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
app:
|
||||||
|
eureka-server: eureka
|
|
@ -1,25 +0,0 @@
|
||||||
spring.application.name=gateway
|
|
||||||
app.eureka-server=localhost
|
|
||||||
|
|
||||||
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
|
|
||||||
server.port=8181
|
|
||||||
server.servlet.context-path=/
|
|
||||||
|
|
||||||
spring.cloud.discovery.enabled=true
|
|
||||||
|
|
||||||
# TODO change these back to lambda's stuffs
|
|
||||||
spring.cloud.gateway.mvc.routes[0].id=discovery-server
|
|
||||||
spring.cloud.gateway.mvc.routes[0].uri=http://${app.eureka-server}:8761
|
|
||||||
spring.cloud.gateway.mvc.routes[0].predicates[0]=Path=/eureka/web
|
|
||||||
spring.cloud.gateway.mvc.routes[0].filters[0]=SetPath=/
|
|
||||||
|
|
||||||
springdoc.enable-javadoc=true
|
|
||||||
springdoc.api-docs.enabled=true
|
|
||||||
springdoc.api-docs.groups.enabled=true
|
|
||||||
springdoc.swagger-ui.enabled=true
|
|
||||||
springdoc.swagger-ui.path=/swagger-ui.html
|
|
||||||
springdoc.swagger-ui.config-url=/v3/api-docs/swagger-config
|
|
||||||
|
|
||||||
|
|
||||||
springdoc.swagger-ui.urls[0].name=Api Gateway APIs
|
|
||||||
springdoc.swagger-ui.urls[0].url=/v3/api-docs
|
|
81
gateway/src/main/resources/application.yml
Normal file
81
gateway/src/main/resources/application.yml
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
server:
|
||||||
|
port: 8181
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: gateway
|
||||||
|
|
||||||
|
cloud:
|
||||||
|
gateway:
|
||||||
|
discovery:
|
||||||
|
locator:
|
||||||
|
enabled: true
|
||||||
|
routes:
|
||||||
|
# eureka service routing
|
||||||
|
- id: eureka
|
||||||
|
# Will only work when docker is used
|
||||||
|
# uri: http://${app.eureka-server}:8761
|
||||||
|
uri: http://localhost:8761
|
||||||
|
predicates:
|
||||||
|
- Path=/eureka/web
|
||||||
|
filters:
|
||||||
|
- SetPath=/
|
||||||
|
- id: eureka-static
|
||||||
|
# Will only work when docker is used
|
||||||
|
# uri: http://${app.eureka-server}:8761
|
||||||
|
uri: http://localhost:8761
|
||||||
|
predicates:
|
||||||
|
- Path=/eureka/**
|
||||||
|
# dummy service routing
|
||||||
|
# TODO smth is wrong with this
|
||||||
|
- id: dummy
|
||||||
|
uri: lb://dummy
|
||||||
|
predicates:
|
||||||
|
- Path=/api/v1/dummy/**
|
||||||
|
filters:
|
||||||
|
- AddResponseHeader=X-Powered-By, LearningPulse Gateway Service
|
||||||
|
security:
|
||||||
|
user:
|
||||||
|
name: admin
|
||||||
|
password: admin
|
||||||
|
|
||||||
|
|
||||||
|
# Keycloak configuration for the future
|
||||||
|
# security:
|
||||||
|
# oauth2:
|
||||||
|
# resourceserver:
|
||||||
|
# jwt:
|
||||||
|
# issuer-uri: ${KEYCLOAK_URL}/realms/LearningPulse
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: "*"
|
||||||
|
endpoint:
|
||||||
|
health:
|
||||||
|
show-details: always
|
||||||
|
gateway:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
springdoc:
|
||||||
|
enable-native-support: true
|
||||||
|
api-docs:
|
||||||
|
enabled: true
|
||||||
|
groups:
|
||||||
|
enabled: true
|
||||||
|
swagger-ui:
|
||||||
|
path: /swagger-ui.html
|
||||||
|
config-url: /v3/api-docs/swagger-config
|
||||||
|
urls:
|
||||||
|
- name: Gateway API
|
||||||
|
url: /v3/api-docs
|
||||||
|
# TODO not working rn
|
||||||
|
- name: Dummy Service API
|
||||||
|
url: /api/v1/dummy/v3/api-docs
|
||||||
|
|
||||||
|
eureka:
|
||||||
|
client:
|
||||||
|
service-url:
|
||||||
|
defaultZone: http://localhost:8761/eureka
|
||||||
|
# Will only work when docker is used
|
||||||
|
# defaultZone: http://${app.eureka-server}:8761/eureka
|
81
pom.xml
Normal file
81
pom.xml
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.2.5</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.learningpulse</groupId>
|
||||||
|
<artifactId>server</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>server</name>
|
||||||
|
<description>API server for LearningPulse</description>
|
||||||
|
<modules>
|
||||||
|
<module>gateway</module>
|
||||||
|
<module>eureka</module>
|
||||||
|
<module>dummy</module>
|
||||||
|
</modules>
|
||||||
|
<properties>
|
||||||
|
<java.version>22</java.version>
|
||||||
|
<maven.compiler.source>22</maven.compiler.source>
|
||||||
|
<maven.compiler.target>22</maven.compiler.target>
|
||||||
|
<spring-cloud.version>2023.0.1</spring-cloud.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>24.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
Reference in a new issue