Add this line to your application's Gemfile:
gem 'action_handler', git: 'git://github.com/qcx/action_handler.git', tag: 'v0.2.0'
And then execute:
$ bundle
# serverless.yml
functions:
listItems:
handler: app/handlers/items_handler.ItemsHandler.index
events:
- http:
method: get
path: items
showItems:
handler: app/handlers/items_handler.ItemsHandler.show
events:
- http:
method: get
path: items/{id}
updateItems:
handler: app/handlers/items_handler.ItemsHandler.update
events:
- http:
method: put
path: items/{id}
# app/handlers/items_handler.rb
class ItemsHandler < ActionHandler::Base
source ActionHandler::Sources::HTTP.new
def index
render json: Item.all
end
def show
render json: Item.find(params[:id])
end
def update
Item.find(params[:id]).update(params)
render status: 204
end
end
Parsed from the received event
- HTTP
- SQS
- SNS
- S3
After checking out the repo, run bin/setup
to install dependencies. Then, run rspec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub at https://github.com/qcx/action_handler. This project is intended to be a safe, welcoming space for collaboration.
- CloudWatch
- DynamoDB
- Kinesis
render status: :ok
render status: :no_content
render json: Item.all # should use Renderers::Json.new(args).render
The gem is available as open source under the terms of the MIT License.