Request:
GET /
Host: tus.example.org
Response:
HTTP/1.1 200 OK
...
Request:
GET /
Host: tus.example.org
Response:
HTTP/1.1 200 OK
...
Request:
GET /
Host: tus.example.org
Response:
HTTP/1.1 200 OK
...
form method='post' action=url(record) | |
fieldset | |
input name='_method' type='hidden' value='link' | |
p | |
input name='link[rel]' type='hidden' value=rel | |
input name='link[id]' type='text' required=true | |
#! /usr/bin/env ruby | |
# Usage: | |
# ruby sequel_dot.rb [SEQUEL-DATABASE-URI] > output.dot | |
# Or pipe directly to Graphviz: | |
# ruby sequel_dot.rb [SEQUEL-DATABASE-URI] | dot -Tgif > output.gif | |
# | |
# Note adapted from Jeremy Evans' and Rohit Namjoshi's son's code at | |
# http://sequel.heroku.com/2010/05/29/fun-with-graphviz-and-associations/ | |
# |
# What am I? A controller? A router? | |
class Foo < Sinatra::Base | |
set :bar, Baz | |
def self.both | |
# aren't a composite object in denial? | |
get '/glee' do | |
'happy!' |
require 'open3' | |
def subprocess(*cmd) | |
Open3.popen3(*cmd) {|i,o,e,t| | |
out = Thread.new do | |
o.each_with_object([]) do |line,memo| | |
memo << line | |
yield line if block_given? | |
end.join |
require 'journey' | |
require 'forwardable' | |
class Router | |
extend Forwardable | |
def_delegator :router, :call | |
def_delegator :formatter, :generate | |
def add_route(app, path, conditions={}, defaults={}, name) | |
routes.add_route( |
class Catalogs < Controller | |
set :model, Catalog | |
set :fields, [:title, :description] | |
namespace '/' do | |
get do | |
catalogs = model.paginate(page, page_size) | |
Link: <http://localhost:5000/catalogs/>; rel="self"; title="Catalog Index" | |
Link: <http://localhost:5000/catalogs/1>; rel="item"; title="Catalog" | |
Link: <http://localhost:5000/catalogs/2>; rel="item"; title="Catalog" | |
... | |
Link: <http://localhost:5000/catalogs/?page=2&page_size=12>; rel="next"; title="Next Page" |