-
Notifications
You must be signed in to change notification settings - Fork 21
Features of Stitches
David Copeland edited this page Jun 25, 2017
·
1 revision
Stitches lets you write an API the same way you'd write regular Rails stuff. To that end, it doesn't do much, but what it does do is useful.
- Requests require an API Key to be specified in the
Authorization
HTTP header. SeeStitches::ApiKey
- The API keys are managed in a database table and you can access the key for each request via
api_client
, implemented in the base controller,ApiController
(see https://github.com/stitchfix/stitches/blob/master/lib/stitches/generator_files/app/controllers/api/api_controller.rb#L15) - Requests must have a versioned content-type. The content type must be
application/json; version=«version»
. SeeStitches::ValidMimeType
- Routing is based on the version in the content type and triggers different controllers. See
Stitches::ApiVersionConstraint
- When rendering JSON, timestamps are properly encoded in ISO 8601. See https://github.com/stitchfix/stitches/blob/master/lib/stitches/render_timestamps_in_iso8601_in_json.rb
- Structured error messages that can be created by hand, from an exception, or from an Active Record. See
Stitches::Errors
- Support for using specs to generate documentation via rspec_api_documentation
- Spec helpers to assert Stitches-like responses easily. See Testing