Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/Hateaos' into develop
- Loading branch information
Showing
8 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>hm.binkley.labs</groupId> | ||
<artifactId>spring-actuator-demo</artifactId> | ||
<version>0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>level</artifactId> | ||
<name>HateoasLevel</name> | ||
<description>REST Nirvana</description> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-parent</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-eureka</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>${lombok.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.plugin</groupId> | ||
<artifactId>spring-plugin-core</artifactId> | ||
<version>1.1.0.RELEASE</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.jayway.jsonpath</groupId> | ||
<artifactId>json-path</artifactId> | ||
<version>0.9.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.hateoas</groupId> | ||
<artifactId>spring-hateoas</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package hello; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import org.springframework.hateoas.ResourceSupport; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
public class Greeting | ||
extends ResourceSupport { | ||
private String message; | ||
|
||
public Greeting() { | ||
} | ||
|
||
@JsonCreator | ||
public Greeting(@JsonProperty("content") final String message) { | ||
this.message = message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package hello; | ||
|
||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import static java.lang.String.format; | ||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; | ||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; | ||
import static org.springframework.http.HttpStatus.OK; | ||
import static org.springframework.web.bind.annotation.RequestMethod.GET; | ||
|
||
@Controller | ||
public class LevelController { | ||
@RequestMapping(value = "/greeting", method = GET) | ||
@ResponseBody | ||
public HttpEntity<Greeting> greet( | ||
@RequestParam(value = "name", required = false, | ||
defaultValue = "World") final String name) { | ||
final Greeting greeting = new Greeting(format("Hello, %s!", name)); | ||
greeting.add(linkTo(methodOn(LevelController.class).greet(name)). | ||
withSelfRel()); | ||
return new ResponseEntity<>(greeting, OK); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package hello; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; | ||
|
||
@EnableEurekaClient | ||
@SpringBootApplication | ||
public class LevelMain { | ||
public static void main(final String... args) { | ||
SpringApplication.run(LevelMain.class, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
info: | ||
build: | ||
artifact: @project.artifactId@ | ||
name: @project.name@ | ||
description: @project.description@ | ||
version: @project.version@ | ||
|
||
server: | ||
port: 8082 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
spring: | ||
application: | ||
name: level | ||
cloud: | ||
config: | ||
uri: http://localhost:8888 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Quiet Netflix - No URLs will be polled as dynamic configuration sources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters