<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/preparing-for-the-plumber-v0-4-0-release-2/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://trestletech.com/2017/07/20/plumber-v0-4-0/"> Trestle Technology, LLC - R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Plumber is a package which allows you to create web APIs from your R code. If you’re new to Plumber, you can take a look at <a rel="nofollow" href="https://www.rplumber.io/" target="_blank">www.rplumber.io</a> to learn more about how to use the package to create your APIs.</p>
<p>Over the years, we’ve noticed a handful of things that we wished we’d done differently in the development of Plumber. In particular, there were some decisions that prioritized convenience over security which we wanted to roll back. We’ve decided to bite the bullet and make these changes before more users start using Plumber. The v0.4.0 release of Plumber includes a handful of breaking changes that mitigate these issues all at once. Our hope in getting all of these out of the way at once is to ensure that users building on Plumber moving forward have confidence that any breaking change under consideration has already been made and that we shouldn’t have this kind of churn again anytime soon.</p>
<p>If you’re already using Plumber, we strongly encourage you to read the v0.4.0 migration guide below. As you’ll see, most of these changes affect the hosting or low-level interactions in Plumber. The dominant mode in which people use Plumber (adding comments to their existing R functions) has not changed; there are no breaking changes in how those files are interpreted.</p>
<p>v0.4.0 of Plumber will be deployed to CRAN in the coming days. We strongly encourage you to try out the v0.4.0 version of Plumber ahead of time to make sure that you’ve migrated your APIs correctly.</p>
<pre><code>devtools::install_github(&quot;trestletech/plumber&quot;)
</code></pre>
<p>Alternatively, you can continue using the last release of Plumber which didn’t include any of these breaking changes (v0.3.3) until you’re ready to upgrade by using the following command:</p>
<pre><code>devtools::install_github(&quot;trestletech/plumber&quot;, ref=&quot;v0.3.3&quot;)
</code></pre>
<p>You can see the full release notes for v0.4.0 <a rel="nofollow" href="https://github.com/trestletech/plumber/blob/master/NEWS.md" target="_blank">here</a>.</p>
<h2>Plumber v0.4.0 Migration Guide</h2>
<p>There are a number of changes that users should consider when preparing to upgrade to <code>plumber</code> v0.4.0.</p>
<ol>
<li><strong>Plumber no longer accepts external connections by default</strong>. The <code>host</code> parameter for the <code>run()</code> method now defaults to <code>127.0.0.1</code>, meaning that Plumber will only listen for incoming requests from the local machine on which it’s running — not from any other machine on the network. This is done for security reasons so that you don’t accidentally expose a Plumber API that you’re developing to your entire network. To restore the old behavior in which Plumber listened for connections from any machine on the network, use <code>$run(host=&quot;0.0.0.0&quot;)</code>. Note that if you’re deploying to an environment that includes an HTTP proxy (such as the <a rel="nofollow" href="https://book.rplumber.io/hosting.html#digitalocean" target="_blank">DigitalOcean</a> servers which use nginx), having Plumber listen only on <code>127.0.0.1</code> is likely the right default, as your proxy — not Plumber — is the one receiving external connections.</li>
<li>Plumber no longer sets the <code>Access-Control-Allow-Origin</code> HTTP header to <code>*</code>. This was previously done for convenience but given the security implications we’re reversing this decision. The previous behavior would have allowed web browsers to make requests of your API from other domains using JavaScript if the request used only standard HTTP headers and were a <code>GET</code>, <code>HEAD</code>, or <code>POST</code> request. These requests will no longer work by default. If you wish to allow an endpoint to be accessible from other origins in a web browser, you can use <code>res$setHeader(&quot;Access-Control-Allow-Origin&quot;, &quot;*&quot;)</code> in an endpoint or filter.</li>
<li>Rather than setting the default port to <code>8000</code>, <strong>the port is now randomly selected</strong>. This ensures that a shared server (like RStudio Server) will be able to support multiple people developing Plumber APIs concurrently without them having to manually identify an available port. This can be controlled by specifying the <code>port</code> parameter in the <code>run()</code> method or by setting the <code>plumber.port</code> option.</li>
<li><strong>The object-oriented model for Plumber routers has changed</strong>. If you’re calling any of the following methods on your Plumber router, you will need to modify your code to use the newer alternatives: <code>addFilter</code>, <code>addEndpoint</code>, <code>addGlobalProcessor</code>, and <code>addAssets</code>. The code around these functions has undergone a major rewrite and some breaking changes have been introduced. These four functions are still supported with a deprecation warning in 0.4.0, but support is only best-effort. Certain parameters on these methods are no longer supported, so you should thoroughly test any Plumber API that leverages any of these methods before deploying version 0.4.0. <a rel="nofollow" href="https://book.rplumber.io/programmatic-usage" target="_blank">Updated documentation</a> for using Plumber programmatically is now available.</li>
</ol>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://trestletech.com/2017/07/20/plumber-v0-4-0/"> Trestle Technology, LLC - R</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/0n51HqwdKsg" height="1"></a></div>