<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brit Gardner ::: Web Developer ::: Dallas, TX &#187; ruby</title>
	<atom:link href="http://britg.com/topics/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://britg.com</link>
	<description>The big yellow one&#039;s the sun.</description>
	<lastBuildDate>Sun, 10 Jan 2010 17:25:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sinatra Authentication with MongoMapper Support</title>
		<link>http://britg.com/2010/01/01/sinatra-authentication-with-mongomapper-support/</link>
		<comments>http://britg.com/2010/01/01/sinatra-authentication-with-mongomapper-support/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 20:56:45 +0000</pubDate>
		<dc:creator>britg</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://britg.com/?p=1297</guid>
		<description><![CDATA[Added support for MongoMapper in the sinatra-authentication gem.  Grab it from http://github.com/britg/sinatra-authentication.
Be sure to require mongo_mapper before sinatra-authentication and everything should work peachy keen.

require 'sinatra/base'
require 'mongo_mapper'
require 'sinatra-authentication'

]]></description>
			<content:encoded><![CDATA[<p>Added support for MongoMapper in the sinatra-authentication gem.  Grab it from <a href="http://github.com/britg/sinatra-authentication">http://github.com/britg/sinatra-authentication</a>.</p>
<p>Be sure to require mongo_mapper before sinatra-authentication and everything should work peachy keen.</p>
<pre class="brush: ruby;">
require 'sinatra/base'
require 'mongo_mapper'
require 'sinatra-authentication'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://britg.com/2010/01/01/sinatra-authentication-with-mongomapper-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cross Origin Resource Sharing with Sinatra</title>
		<link>http://britg.com/2009/12/29/cross-origin-resource-sharing-with-sinatra/</link>
		<comments>http://britg.com/2009/12/29/cross-origin-resource-sharing-with-sinatra/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 15:46:45 +0000</pubDate>
		<dc:creator>britg</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[cors]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://britg.com/?p=1282</guid>
		<description><![CDATA[It&#8217;s no lie that I think highly of the potential of Cross Origin Resource Sharing.  One of the great things about it is that it doesn&#8217;t take much re-wiring of existing server (or client-side) apps to start working cross domain.
Enabling your server app is as simple as including a few extra headers when you [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s no lie that <a href="http://britg.com/2009/12/02/cross-origin-resource-sharing/">I think highly</a> of the potential of Cross Origin Resource Sharing.  One of the great things about it is that it doesn&#8217;t take much re-wiring of existing server (or client-side) apps to start working cross domain.</p>
<p>Enabling your server app is as simple as including a few extra headers when you detect a cross origin request.  How do you know it&#8217;s a cross origin request?  You&#8217;ll see the <code>Origin:</code> header &#8212; all CORS requests will have it.  From there, response headers depend on the specifics of the request, but I won&#8217;t go over those here &#8212; check out the <a href="https://developer.mozilla.org/En/HTTP_access_control">Mozilla Developer Center treatment</a> for in-depth information.</p>
<p>I&#8217;ve been working with Sinatra a lot lately, so I put together <a href="http://github.com/britg/sinatra-cross_origin">an extension for Sinatra</a> that makes enabling Cross Origin requests even easier.</p>
<p><code>sudo gem install sinatra-cross_origin</code></p>
<p>There are two ways to use the extension: globally or per-route.</p>
<h3>Global</h3>
<p>For when you want to share all your endpoints cross-domain.</p>
<pre class="brush: ruby;">

require 'sinatra/base'
require 'sinatra/cross_origin'

class MyApp &lt; Sinatra::Base
  register Sinatra::CrossOrigin

  enable cross_origin

  get '/' do
    &quot;This is available to cross domain javascript requests automatically&quot;
  end
end
</pre>
<h3>Per Route</h3>
<p>For when you want to share only some of your routes cross-domain.</p>
<pre class="brush: ruby;">

require 'sinatra/base'
require 'sinatra/cross_origin'

class MyApp &lt; Sinatra::Base
  register Sinatra::CrossOrigin

  get '/' do
    cross_origin
    &quot;This is available to cross domain javascript requests&quot;
  end
end
</pre>
<h3>Configuration</h3>
<p>You can mix and match app-wide config and request specific config.</p>
<pre class="brush: ruby;">

require 'sinatra/base'
require 'sinatra/cross_origin'

class MyApp &lt; Sinatra::Base
  register Sinatra::CrossOrigin

  configure do
    # Comma separate list of remote hosts that are allowed.
    # :any will allow any host
    set :allow_origin, :any

    # HTTP methods allowed
    set :allow_methods, [:get, :post]

    # Allow cookies to be sent with the requests
    set :allow_credentials, true
  end

  get '/' do
    # Only available to GET requests originating from
    # http://example.com.  No cookies allowed.
    cross_origin :allow_origin =&gt; 'http://example.com',
      :allow_methods =&gt; [:get],
      :allow_credentials =&gt; false
    &quot;This is available to cross domain javascripts&quot;
  end
end
</pre>
<p>Grab the source at Github: <a href="http://github.com/britg/sinatra-cross_origin">britg/sinatra-cross_origin</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://britg.com/2009/12/29/cross-origin-resource-sharing-with-sinatra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
