Hi Sandeep,

Unfortunately that function is only available in 1.10 or 0.13 or later which I 
don’t have access to. Do the $postfix, $prefix, and $infix also work with 
frontend ‘path’ instead of ‘url’?

Regards,
Christopher Jackson


> On Jul 27, 2018, at 2:16 PM, Sandeep Moré <moresand...@gmail.com> wrote:
> 
> It should be possible using parameterized rewrite variables, this is an 
> example from Spark History rewrite rules 
> 
> <!-- re-write rule for location when SHS redirects to Knox SSO login page -->
> <rule dir="OUT" 
> name="SPARKHISTORYUI/sparkhistory/outbound/headers/location/sso">
>   <match 
> pattern="{scheme}://{host}:{port}/{gateway}/{knoxsso}/{api}/{v}/websso?originalUrl={**}"/>
>   <rewrite 
> template="{scheme}://{host}:{port}/{gateway}/{knoxsso}/{api}/{v}/websso?originalUrl={$postfix[url,/sparkhistory/]}"/>
> </rule>
> <filter name="SPARKHISTORYUI/sparkhistory/outbound/headers/sso/filter">
>   <content type="application/x-http-headers">
>     <apply path="Location" 
> rule="SPARKHISTORYUI/sparkhistory/outbound/headers/location/sso"/>
>   </content>
> </filter>
> 
> or in the above example
> 
> <rewrite 
> template="{$frontend[url]}/api/v1/websso?originalUrl={scheme}://{host}:{port}/{gateway}/{knoxsso}/"/>
> 
> Best,
> Sandeep
> 
> 
> 
> On Fri, Jul 27, 2018 at 1:03 PM Christopher Jackson 
> <jackson.christopher....@gmail.com 
> <mailto:jackson.christopher....@gmail.com>> wrote:
> Hi All,
> 
> Curious if it is possible to rewrite a query parameter value to append a 
> string to the original value? I tried the below configuration but I don’t 
> think its valid as requests to the resource were just hanging.
> 
> Entry from service.xml for the particular path:
> 
> <rewrite apply=“MYSERVICE/myapp/outbound/redirect/headers" 
> to="response.headers"/>
> 
> 
> Entries in rewrite.xml:
> 
> <rule dir="OUT" name="MYSERVICE/myapp/outbound/redirect/headers/location">
>     <match pattern=“*://*:*/myapp?originalUrl={originalurl}&{**}"/>
>     <rewrite 
> template="{$frontend[url]}/myservice/myapp?originalUrl={originalurl}&{**}"/>
> </rule>
> 
> <filter name="MYSERVICE/myapp/outbound/redirect/headers">
>     <content type="application/x-http-headers">
>         <apply path="Location" 
> rule="MYSERVICE/myapp/outbound/redirect/headers/location"/>
>     </content>
> </filter>
> 
> An additional concern I have with the above attempted approach is I don’t 
> think that I can guarantee the order of the query parameters.
> 
> 
> 
> An example of what I would like to see happen is the header content of a 302 
> response with a Location header value of:
> 
> https://host.example.com:9443/myapp?originalUrl=/some/path/&mode=EI&wrongRole=true
>  
> <https://host.example.com:9443/myapp?originalUrl=/some/path/&mode=EI&wrongRole=true>
> 
> to be rewritten to:
> 
> https://host.example.com:8443/gateway/default/myservice/myapp?originalUrl=/gateway/default/myservice/myapp/some/path/&mode=EI&wrongRole=true
>  
> <https://host.example.com:8443/gateway/default/myservice/myapp?originalUrl=/gateway/default/myservice/myapp/some/path/&mode=EI&wrongRole=true>
> 
> In summary the result would have the frontend[url] replace the internal 
> destination and the originalUrl query parameter would have the frontend[path] 
> appended to its original value.
> 
> Anyone have any ideas on how to achieve this?
> 
> Regards,
> Christopher Jackson

Reply via email to