Skip to content

Latest commit

 

History

History

spring

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Rhyme - Spring Boot Integration

Maven Central

This module contains API interfaces and Spring beans to simplify using Rhyme to build a HAL microservice as a Spring Boot application.

Usage

Simply add this module as a dependency to your Spring Boot project, and the extensions explained below should become effective through auto-configuration.

It currently doesn't give you much control to configure or replace the default behaviour that will become effective through auto-configuration by simply adding this module as a dependency.

If you want to use Rhyme in an existing application, there are some areas where it can break your application (e.g. exception handling). Also the integration module relies on @RequestScoped beans, so it may not be suitable if your service will use additional threads.

In any case, you can always just use the core module instead, and use the Spring integration implementation classes as inspiration for the required glue code.

Suggestions and PRs to extend this module to support more use cases are of course always welcome!

Key Differences and Extensions to Rhyme Core Module

  • You usually don't have to interact with RhymeBuilder to configure and create a Rhyme instance yourself
  • Instead, you can use @Autowire to inject a request-scoped SpringRhyme bean into your application
    • this SpringRhyme instance will allow you to fetch remote resources (using a Spring WebClient), or modify your response's max-age
  • To render a resource, simply return a LinkableResource instance (that also implements a @HalApiInterface) from your @RestController's request handling method
  • You can use the UrlFingerprinting and RhymeLinkBuilder interfaces to create fingerprinted links to your controller methods (with the help of Spring HATEOAS's WebMvcLinkBuilder)
  • Any exceptions thrown by your resources (or by the Spring framework) will be caught by Rhyme and rendered as a vnd.error resource

Examples

Documentation