Sha256: c5a51d7b91b4f2e1b823cee3d288444037e8d6839d5899d945bd248988e8290b

Contents?: true

Size: 520 Bytes

Versions: 6

Compression:

Stored size: 520 Bytes

Contents

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

# Just run `ruby examples/basic_auth.rb` and then use something like
# `curl http://localhost:2345/api/v1/` or
# `curl http://localhost:2345/api/v1/This%20is%20so%20cool`.

require "rack/api"

Rack::API.app do
  prefix "api"

  helper do
    def default_message
      "Hello from Rack API"
    end
  end

  version :v1 do
    get "/(:message)" do
      {:message => params.fetch(:message, default_message)}
    end
  end
end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rack-api-1.1.0 examples/helpers.rb
rack-api-1.0.2 examples/helpers.rb
rack-api-1.0.1 examples/helpers.rb
rack-api-1.0.0 examples/helpers.rb
rack-api-0.3.1 examples/helpers.rb
rack-api-0.3.0 examples/helpers.rb