Sha256: 746de11115a67c457870eb88e0fdefca044249a80f47586128d7088d33f60947

Contents?: true

Size: 430 Bytes

Versions: 1

Compression:

Stored size: 430 Bytes

Contents

require 'sinatra'
require 'lib/sinatra/scopes'

Project = {'a' => 'Project A', 'b' => 'Project B'}
User = {'1' => 'User 1', '2' => 'User 2'}

scope :project, '/projects/*' do |project_id|
  @project = Project[project_id]
end

project.get '/users/*' do |user_id|
  @user = User[user_id]
  "#{@project}, #{@user}"
end

helpers do
  def auth; true end
end

scope(:authorized) { auth }

authorized.get '/sekret/*' do |page|
  page
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra-scopes-1.0.0 example_app.rb