Created
June 10, 2015 18:11
-
-
Save soopa/c70fbba488f1bac24e8d to your computer and use it in GitHub Desktop.
Basic Last.rb Example
This file contains 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
require "rack" | |
require "last/endpoints" | |
require "last/routers" | |
require "last/middlewares/body_parser_for_json_content_type" | |
class Router < Last::Routers::Router | |
get "/accounts", Application::V1::ListAccountsEndpoint | |
end | |
class ListAccountsEndpoint < Last::Endpoints::Endpoint | |
def command | |
interactor = ListAccountsInteractor.new.call | |
response.status = 200 | |
AccountRepresenter.new(interactor.accounts).to_json(:detail) | |
end | |
end | |
run Rack::Builder.new { | |
use Last::Middlewares::BodyParserForJsonContentType | |
run Router.new | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment