Spring Data Rest
Spring Data REST is part of the umbrella Spring Data project and makes it easy to build hypermedia-driven REST web services on top of Spring Data repositories.
To add
org.springframework.boot
The Spring auto configuration scans all repositories and publish them as REST API
Spring Data REST is using the HATEOAS (Hypermedia As The Engine Of Application State) principle and supports HAL (Hypertext Application Language) as a semantic layer for metadata (like linking) on top of it.
The principle of HATEOAS is that each resource has its own URI (aka endpoint), and you always transfer the whole state of your object behind an endpoint
The other important idea behind this principle is that clients shall only know one entry point to your API and can discover the API without any out of bound information like documentation in a wiki or word file.
A RepositoryDetectionStrategy is used to determine which repositories should be exposed in the API.
All these model objects support spring data rest
@Configuration public class RepositoryConfiguration implements RepositoryRestConfigurer { @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { config.exposeIdsFor(BackendTask.class); config.exposeIdsFor(GenericRun.class); config.exposeIdsFor(JobResume.class); config.exposeIdsFor(PlugMillingData.class); config.exposeIdsFor(PlugMillingRun.class); config.exposeIdsFor(Problem.class); config.exposeIdsFor(Run.class); config.exposeIdsFor(RunFile.class); config.exposeIdsFor(User.class); config.exposeIdsFor(WellDetail.class); config.exposeIdsFor(FileData.class); } }
HAL is a simple format that gives a consistent and easy way to hyperlink between resources in your Rest API.
Adopting HAL will make your API explorable, and its documentation easily discoverable from within the API itself. In short, it will make your API easier to work with and therefore more attractive to client developers.
HAL Browser
You can access the HAL browser by the following generic link
For more info
No comments:
Post a Comment