Skip to content

Instantly share code, notes, and snippets.

@dnesteryuk
Created May 22, 2020 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnesteryuk/3e4af9af179dacf7161ffd3a02710223 to your computer and use it in GitHub Desktop.
Save dnesteryuk/3e4af9af179dacf7161ffd3a02710223 to your computer and use it in GitHub Desktop.
require 'grape'
class API < Grape::API
prefix :api
version 'v1', using: :path
resources :users do
desc 'return all users'
get '/' do
puts 'Users'
end
desc 'returns a user'
params do
requires :id, type: Integer
end
get ':id' do
puts "User: #{params[:id]}"
end
end
end
options = {
method: 'GET'
}
env = Rack::MockRequest.env_for('/api/v1/users/12', options)
API.call env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment