Hello,
I am wondering how I can retrieve at runtime the connection information. That
is, scheme, host, port, virtual host, etc.
I am setting up Pax-Web to use a specific Jetty connector, which is configured
externally, like this:
<service
interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
<service-properties>
<entry key="httpContext.id">
<value>internalAPIContext</value>
</entry>
</service-properties>
<bean
class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
<property name="httpContextId"
value="internalAPIContext" />
<property name="path"
value="#{context.path}#{api.root.path}" />
<property name="parameters">
<map>
<entry key="httpContext.virtualhosts"
value="127.0.0.1"/>
<entry key="httpContext.connectors"
value="internalAPIConnector"/>
</map>
</property>
</bean>
</service>
The use case is that my rest service need to return full URLs, with scheme,
host, port, etc. so I don’t want to hard code this, but extract it dynamically.
In the log file I see something like this:
2020-02-05T13:09:26,308 | INFO | paxweb-config-1-thread-2 | AbstractConnector
| 239 - org.eclipse.jetty.util - 9.4.22.v20191022 | Stopped
internalAPIConnector@6c6781c7{HTTP/1.1,[http/1.1]}{127.0.0.1:8285}
Which suggest this information is known by Pax-Web.
Is it possible to query this at runtime?
Best regards,
Alex soto