<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged ring</title>
<link>https://ask.clojure.org/index.php/tag/ring</link>
<description></description>
<item>
<title>Problem in production when removing wrap-reload</title>
<link>https://ask.clojure.org/index.php/9262/problem-in-production-when-removing-wrap-reload</link>
<description>&lt;p&gt;I'm setting up a service that returns a JSON, thanks to Ring, Compojure and Jetty. The problem I have is when I want to use Nginx as a reverse proxy. If I use the following handlers it doesn't work.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def wrapped-handler
  ;; Handler middlewares
  (-&amp;gt; all-routes
      (wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))
      wrap-params
      wrap-session
      ))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The message I get back is&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;java.lang.NullPointerException
        at ring.adapter.jetty$proxy_handler$fn__6990.invoke(jetty.clj:26)
        at ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
        at org.eclipse.jetty.server.Server.handle(Server.java:503)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
        at java.base/java.lang.Thread.run(Thread.java:834)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But if I add wrap-reload everything goes right.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def wrapped-handler
  ;; Handler middlewares
  (-&amp;gt; all-routes
      (wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))
      wrap-params
      wrap-session
      (#(if (config :debug) (wrap-reload %)))
      ))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My setup with Nginx is as follows.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;server {        

        server_name domain.com;

        location / {
            proxy_pass http://localhost:9000/;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_redirect  off;
        }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is it safe to leave wrap-reload in production? &lt;br&gt;
What have I left behind?&lt;/p&gt;
&lt;p&gt;Thank you all in advance.&lt;/p&gt;
</description>
<category>Libs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9262/problem-in-production-when-removing-wrap-reload</guid>
<pubDate>Sat, 25 Apr 2020 16:47:42 +0000</pubDate>
</item>
<item>
<title>Role of application state in a Ring webserver</title>
<link>https://ask.clojure.org/index.php/9165/role-of-application-state-in-a-ring-webserver</link>
<description>&lt;p&gt;Getting started with Ring. I am most familiar with web development in php, in which the php application is booted afresh on every request, which is proxied to by the web server, e.g. apache.&lt;/p&gt;
&lt;p&gt;That of course means it is not possible that the php application itself can maintain any in-memory state (PHP enforcing a &quot;shared nothing&quot; architecture). So,  I do note that in other languages such as java and Clojure the server is a long running process and there is therefore an option for global state.   I aim to stick to 12-factor principles, though, and so I understand application state should be avoided, as if I was programming in php, perhaps.&lt;/p&gt;
&lt;p&gt;I've got initial awareness about the reloaded workflow and such like. Of course, that makes sense in many cases.&lt;/p&gt;
&lt;p&gt;However, since I am aiming that the web app I now write have no global state, would that mean I don't actually need a reloaded workflow (and hence lein ring would be enough - just to reload the code, not the state).&lt;/p&gt;
&lt;p&gt;I wonder if there is anything I am missing.  e.g. what if I change a config variable, maybe that counts as 'state', and would require a reload. Yes, I'll test this myself in due course to find out.&lt;/p&gt;
&lt;p&gt;But just looking for any general tips / discussion on these points to help get off on the right foot.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9165/role-of-application-state-in-a-ring-webserver</guid>
<pubDate>Thu, 19 Mar 2020 17:18:33 +0000</pubDate>
</item>
<item>
<title>Redirection with Ring forcing GET</title>
<link>https://ask.clojure.org/index.php/8629/redirection-with-ring-forcing-get</link>
<description>&lt;p&gt;Hi! I'm having a problem doing a redirection with Ring. If I'm on a page with the POST method, doing the redirection will keep it. How can I force all my redirections to be GET? Thank you in advance.&lt;/p&gt;
</description>
<category>Libs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8629/redirection-with-ring-forcing-get</guid>
<pubDate>Fri, 20 Sep 2019 15:46:10 +0000</pubDate>
</item>
</channel>
</rss>