This talk was given to the Fall 2013 cohort of Launch Academy. The talk explains the difference between traditional web applications in the context of Rails and data-only applications that expose their functionality through REST+JSON interfaces.
be more difficult (clients and APIs tend to be tested in isolation) Clients risk falling out of date as API updates are released (requiring a non- breaking, backwards-compatible versioning strategy) Wednesday, October 23, 13
usually unneeded Rails functionalities for API applications.” http://blog.wyeworks.com/2012/4/20/rails-for-api-applications-rails-api-released/ Wednesday, October 23, 13
use Rack::Runtime use Rack::MethodOverride use ActionDispatch::RequestId use Rails::Rack::Logger use ActionDispatch::ShowExceptions use ActionDispatch::DebugExceptions use ActionDispatch::RemoteIp use ActionDispatch::Reloader use ActionDispatch::Callbacks use ActiveRecord::Migration::CheckPending use ActiveRecord::ConnectionAdapters::ConnectionManagement use ActiveRecord::QueryCache use ActionDispatch::Cookies use ActionDispatch::Session::CookieStore use ActionDispatch::Flash use ActionDispatch::ParamsParser use Rack::Head use Rack::ConditionalGet use Rack::ETag use MetaRequest::Middlewares::MetaRequestHandler use MetaRequest::Middlewares::Headers use MetaRequest::Middlewares::AppRequestHandler rails middleware stack Wednesday, October 23, 13
use Rack::Runtime use ActionDispatch::RequestId use Rails::Rack::Logger use ActionDispatch::ShowExceptions use ActionDispatch::DebugExceptions use ActionDispatch::RemoteIp use ActionDispatch::Reloader use ActionDispatch::Callbacks use ActiveRecord::Migration::CheckPending use ActiveRecord::ConnectionAdapters::ConnectionManagement use ActiveRecord::QueryCache use ActionDispatch::ParamsParser use Rack::Head use Rack::ConditionalGet use Rack::ETag rails-api middleware stack Wednesday, October 23, 13
use Rack::Runtime use Rack::MethodOverride use ActionDispatch::RequestId use Rails::Rack::Logger use ActionDispatch::ShowExceptions use ActionDispatch::DebugExceptions use ActionDispatch::RemoteIp use ActionDispatch::Reloader use ActionDispatch::Callbacks use ActiveRecord::Migration::CheckPending use ActiveRecord::ConnectionAdapters::ConnectionManagement use ActiveRecord::QueryCache use ActionDispatch::Cookies use ActionDispatch::Session::CookieStore use ActionDispatch::Flash use ActionDispatch::ParamsParser use Rack::Head use Rack::ConditionalGet use Rack::ETag use MetaRequest::Middlewares::MetaRequestHandler use MetaRequest::Middlewares::Headers use MetaRequest::Middlewares::AppRequestHandler rails-api vs rails middleware Wednesday, October 23, 13
Created, etc) 4xx - Client error (e.g. 401 Unauthorized, 403 Forbidden, 404 Not Found, etc) 5xx - Server Error (something went wrong on the server side, not uncommon) Great resource: http://httpstatus.es/ Wednesday, October 23, 13
Rails, just lighter. Integration Testing Use Rack::Test, RSpec Request Specs Test HTTP status codes and response bodies Version your API Secure your API Document your API Wednesday, October 23, 13