Last active
May 11, 2017 12:05
-
-
Save sebglazebrook/e28e1af2ae881560b629030124913304 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is similar to a controller in rails | |
# each method represents a verb/action from rest | |
class User < Resource | |
include JsonRendering | |
def options | |
end | |
def head | |
end | |
def get(params = {}) | |
# do whatever you want here we | |
# entirely up to the user | |
json_render UserRepo.all | |
end | |
def get_by_id(id, params = {}) | |
# do whatever you want here we | |
# entirely up to the user | |
json_render UserRepo.find_by_id(id) | |
end | |
def post(id, params = {}) | |
end | |
def put(id, params = {}) | |
end | |
def patch(id, params = {}) | |
end | |
def delete(id, params = {}) | |
end | |
end | |
# this is similar to the routes.rb file in rails | |
class Router < ResourceRouter | |
route :users, at: "/people" | |
route :posts do | |
route :comments, only: [:get] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment