public class EmbedHelper
extends java.lang.Object
implements javax.ws.rs.core.Feature
if (embedHelper.isEmbeddingOfRelationRequested("owner")) { carResource.setOwner(createPerson(ownerId)); }
Clients may request to resolve a link as an embedded resource by appending the query param
embed
to the request uri containing all the named relations they want to embed. embed
may be be added multiple times to create an array of relation names or contain multiple
relation names separated by comma, e.g.:
GET /api/cars?embed=drivers&embed=owner
GET /api/cars?embed=drivers,owner
Constructor and Description |
---|
EmbedHelper(io.dropwizard.setup.Environment environment)
Create a new embed helper instance and register it in the given
environment so that it
becomes Context aware. |
Modifier and Type | Method and Description |
---|---|
boolean |
configure(javax.ws.rs.core.FeatureContext context) |
boolean |
isEmbeddingOfRelationRequested(java.lang.String relationName) |
public EmbedHelper(io.dropwizard.setup.Environment environment)
environment
so that it
becomes Context
aware.environment
- The Dropwizard environment to register this instance in.public boolean isEmbeddingOfRelationRequested(java.lang.String relationName)
relationName
- the name of the relation, e.g. project
in @{code { "_links":
{"project": {"href": "http..."}}}}public boolean configure(javax.ws.rs.core.FeatureContext context)
configure
in interface javax.ws.rs.core.Feature