]
Marek Kopecký commented on WFLY-3212:
-------------------------------------
bq. my problem is I need the baseUri in a piece of code I can't Inject into, (a sub
object of an entity).
[~xenoterracide]: Can you please share an example? I tried this and it works as expected:
{code:java}
public class CustomObject {
public String get() {
UriInfo uriInfo = ResteasyProviderFactory.getContextData(UriInfo.class);
return uriInfo.getAbsolutePath().toString();
}
}
@Path("/")
public class Resource {
@GET
@Path("a")
public String getDemoValue() {
CustomObject customObject = new CustomObject();
return customObject.get();
}
}
{code}
Access Base URI without CDI
---------------------------
Key: WFLY-3212
URL:
https://issues.jboss.org/browse/WFLY-3212
Project: WildFly
Issue Type: Feature Request
Components: REST
Reporter: Caleb Cushing
Priority: Minor
I need to get at the baseUri, I'm familliar with this
@Context
UriInfo uriInfo;
my problem is I need the baseUri in a piece of code I can't Inject into, (a sub
object of an entity). I could pass `uriInfo` or the builder down but that doesn't seem
ideal, as most of the objects have no business knowing about it. The end goal is HATEOAS
URI's in my JSON responses, but I don't need it to be a JAX-RS specific solution,
I figure if I can just get at the Base URI either in my jackson converters, or entities, I
can create the `URIBuilder` from there. It seems to me that once the app is deployed the
base uri could be a global singleton.
This is requesting a feature that allows me to access the base uri in the application or
a URIBuilder similar to UriInfo.getBaseUriBuilder() except without requiring that the
object be injected, this object would obviously not have request specific information