ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saurabh Sharma <saurabh.sha...@nviz.com>
Subject RE: Jetty configuration for adding new Handler
Date Fri, 24 Jun 2016 10:10:40 GMT
Hi,

Could anyone please tell us how to add response header "Access-Control-Allow-Origin" in the
response returned from the rest call to ignite.

Thanks,
Saurabh

From: Saurabh Sharma [mailto:saurabh.sharma@nviz.com]
Sent: Thursday, June 23, 2016 7:46 PM
To: user@ignite.apache.org
Subject: Jetty configuration for adding new Handler

Hi,

We are using  ignite-rest-http module to make Rest http calls. For that we have included ignite-rest-http
dependency in our ignite module and are able to make http calls successfully.

Now when we are trying to configure Jetty's RewriteHandler to set HeaderPatternRule to set
"Access-Control-Allow-Origin" this handler is not being called and response header is not
being set when we make http call.
However I could see this handler being set at the time of ignite startup during debugging.

We are using following configuration. Could you please suggest if we are missing anything.

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
    <Arg name="threadPool">
        <!-- Default queued blocking thread pool -->
        <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
            <Set name="minThreads">20</Set>
            <Set name="maxThreads">200</Set>
        </New>
    </Arg>
    <New id="httpCfg" class="org.eclipse.jetty.server.HttpConfiguration">
        <Set name="secureScheme">https</Set>
        <Set name="securePort">8443</Set>
        <Set name="sendServerVersion">true</Set>
        <Set name="sendDateHeader">true</Set>
    </New>
                <New id="RewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
                  <Set name="rules">
                                <Array type="org.eclipse.jetty.rewrite.handler.Rule">

                                  <Item>
                                                <New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
                                                  <Set name="pattern">*.*</Set>
                                                  <Set name="name">myheader</Set>
                                                  <Set name="value">the value of myheader</Set>
                                                </New>
                                  </Item>

                                </Array>
                  </Set>
                </New>
    <Call name="addConnector">
        <Arg>
            <New class="org.eclipse.jetty.server.ServerConnector">
                <Arg name="server"><Ref refid="Server"/></Arg>
                <Arg name="factories">
                    <Array type="org.eclipse.jetty.server.ConnectionFactory">
                        <Item>
                            <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                                <Ref refid="httpCfg"/>
                            </New>
                        </Item>
                    </Array>
                </Arg>
                <Set name="host">
                  <SystemProperty name="IGNITE_JETTY_HOST" default="localhost"/>
                </Set>
                <Set name="port">
                  <SystemProperty name="IGNITE_JETTY_PORT" default="8080"/>
                </Set>
                <Set name="idleTimeout">30000</Set>
                <Set name="reuseAddress">true</Set>
            </New>
        </Arg>
    </Call>
    <Set name="handler">
        <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
            <Set name="handlers">
                <Array type="org.eclipse.jetty.server.Handler">
                    <Item>
                        <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
                    </Item>
                </Array>
            </Set>
        </New>
    </Set>

                <New id="RewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
                  <Set name="rules">
                                <Array type="org.eclipse.jetty.rewrite.handler.Rule">

                                  <Item>
                                                <New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
                                                  <Set name="pattern">*.*</Set>
                                                  <Set name="name">Access-Control-Allow-Origin</Set>
                                                  <Set name="value">*</Set>
                                                </New>
                                  </Item>

                                </Array>
                  </Set>
                </New>

                <Set name="handler">
                  <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
                                <Set name="handlers">
                                  <Array type="org.eclipse.jetty.server.Handler">
                                                <Item>
                                                  <Ref refid="RewriteHandler"/>
                                                </Item>
                                  </Array>
                                </Set>
                  </New>
                </Set>
    <Set name="stopAtShutdown">false</Set>
</Configure>

Thanks,
Saurabh

IMPORTANT NOTICE: This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If you have received
this email in error, please notify the system manager and/or the sender immediately.

Mime
View raw message