-
Notifications
You must be signed in to change notification settings - Fork 6
Resources
They contain the ruby code to execute for each request. They're the entry point like the controllers in rails.
If adding a 'posts' resource, add a class in resources/posts.rb
called Posts
that inherits from AngusBase::Resource
like this:
class Posts < AngusBase::Resource
def index
end
end
Make sure the method name matches the action declared in operations.yml.
Being a rack based application you can access the elements defined in request
and uri
by the operations.yml for this action with params[:parameter_key]
.
For example if you set the path to '/posts/:id' you can access it with params[:id]. It's the same for elements declared inside of request.
The method in the resource needs to return a hash with at least the required keys declared under response for the operation. Take a look at this simple example how the hash returned by the method in the resource matches the definition in operations.yml.