io.quarkus.resteasy.reactive.links.runtime.hal.ResteasyReactiveHalService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-rest-links Show documentation
Show all versions of quarkus-rest-links Show documentation
Web Links support for Quarkus REST. Inject web links into response HTTP headers by annotating your endpoint resources.
package io.quarkus.resteasy.reactive.links.runtime.hal;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Link;
import io.quarkus.hal.HalLink;
import io.quarkus.hal.HalService;
import io.quarkus.resteasy.reactive.links.RestLinksProvider;
@RequestScoped
public class ResteasyReactiveHalService extends HalService {
private final RestLinksProvider linksProvider;
@Inject
public ResteasyReactiveHalService(RestLinksProvider linksProvider) {
this.linksProvider = linksProvider;
}
@Override
protected Map getClassLinks(Class> entityType) {
return linksToMap(linksProvider.getTypeLinks(entityType));
}
@Override
protected Map getInstanceLinks(Object entity) {
return linksToMap(linksProvider.getInstanceLinks(entity));
}
private Map linksToMap(Collection refLinks) {
Map links = new HashMap<>();
for (Link link : refLinks) {
links.put(link.getRel(), new HalLink(link.getUri().toString(), link.getTitle(), link.getType()));
}
return links;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy