Skip to content

Minimal Sinatra Example App

GavinJoyce edited this page Mar 17, 2013 · 3 revisions

View the source: https://github.com/RestPack/sample-apps/tree/master/sinatra-sample

First the app:

require 'sinatra'
require 'restpack-web'

class App < Sinatra::Base
  include RestPack::Web::Sinatra::App

  get '/' do
    erb :index
  end
end

Then the view:

<div>
  Welcome to the sample RestPack Sinatra app

  <hr />

  <% if @restpack.user %>
    <h1>Hi <%= @restpack.user['name'] %></h1>
    <a href="<%= @restpack.logout_url() %>">Logout</a>
  <% else %>
    Login with :
    <a href="<%= @restpack.login_url(:twitter) %>">Twitter</a> |
    <a href="<%= @restpack.login_url(:google_oauth2) %>">Google</a>
  <% end %>

  <hr />

  <%= Maruku.new(@restpack.debug_info).to_html %>
</div>

Then boom goes the dynamite:

RestPack

Clone this wiki locally