Sha256: 2defee9fbe73986b6cef631d4cde99b148dbe887509cc9a3ae1ad9fa649c727d

Contents?: true

Size: 593 Bytes

Versions: 11

Compression:

Stored size: 593 Bytes

Contents

$:.push(File.dirname(__FILE__) + "/../lib")

# Just run `ruby examples/formats.rb` and then use something like
# `curl http://localhost:2345/api/v1/hello.xml`.

require "rack/api"
require "active_support/all"

module Rack
  class API
    module Formatter
      class Xml < Base
        def to_format
          object.to_xml(:root => :messages)
        end
      end
    end
  end
end

Rack::API.app do
  prefix "api"
  respond_to :xml

  version :v1 do
    get "/hello(.:format)" do
      {:message => "Hello from Rack API"}
    end
  end
end

Rack::Handler::Thin.run Rack::API, :Port => 2345

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rack-api-1.1.0 examples/custom_format.rb
rack-api-1.0.2 examples/custom_format.rb
rack-api-1.0.1 examples/custom_format.rb
rack-api-1.0.0 examples/custom_format.rb
rack-api-0.3.1 examples/custom_format.rb
rack-api-0.3.0 examples/custom_format.rb
rack-api-0.2.2 examples/custom_format.rb
rack-api-0.2.1 examples/custom_format.rb
rack-api-0.2.0 examples/custom_format.rb
rack-api-0.1.2 examples/custom_format.rb
rack-api-0.1.1 examples/custom_format.rb