karaf http redirect

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

karaf http redirect

smunro
This post has NOT been accepted by the mailing list yet.
Hello,

I have small problem getting http requests to localhost:8181 to redirect to a cxf rest service bound to
org.apache.cxf.servlet.context=/demo-client/api (inside org.apache.cxf.osgi).

I've got the http feature installed, but I've been asked to allow requests to localhost:8181 to be directed to localhost:8181/demo-client/api

I don't have any servlets, just pojo classes with annotated JAX-RS and a blueprint file to configure the rest server.

Any suggestions on how to go about this. I'm hoping it's fairly trivial.
Reply | Threaded
Open this post in threaded view
|

Re: karaf http redirect

smunro
This post has NOT been accepted by the mailing list yet.
As addendum,

I have tried the following:

<service ref="rewriteHandler"
                interface="org.eclipse.jetty.server.Handler"/>
                                               
        <bean id="rewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
                <property name="rewriteRequestURI" value="true"/>
                <property name="rewritePathInfo" value="false"/>
                <property name="originalPathAttribute" value="requestedPath"/>
                <property name="rules">
                        <list>
                           <ref component-id="redirectPatternRule"/>
                        </list>                       
                </property>               
        </bean>
       
        <bean id="redirectPatternRule" class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
                <property name="terminating" value="true"/>
                <property name="pattern" value="/"/>
                <property name="location" value="/demo-client"/>
        </bean>   

Which does redirect localhost:8080 to /demo-client, but if I refresh the page, it's completely blank. I'm not sure if this is the correct way to override routing via karaf or if I'm just missing a few extra things.
Reply | Threaded
Open this post in threaded view
|

Re: karaf http redirect

smunro
This post has NOT been accepted by the mailing list yet.
Seems I got round the problem by making   <property name="pattern" value=""/>
otherwise I could have used regex. In any case, this seems to be the simplest approach.