Skip to content

Instantly share code, notes, and snippets.

@soopa
Created June 10, 2015 18:11
Show Gist options
  • Save soopa/c70fbba488f1bac24e8d to your computer and use it in GitHub Desktop.
Save soopa/c70fbba488f1bac24e8d to your computer and use it in GitHub Desktop.
Basic Last.rb Example
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