Praxis v0.11 Release Notes
-
MediaTypeCollection
:- Added support for loading
decorate
edResource
associations.
- Added support for loading
- ๐ Refined and enhanced support for API versioning:
- version DSL now can take a
using
option which specifies and array of the methods are allowed::header
,:params
,:path
(new) - if not specified, it will default to
using: [:header, :params]
(so that the version can be passed to the header OR the params) - the new
:path
option will build the action routes by prefixing the version given a common pattern (i.e., "/v1.0/...") - The effects of path versioning will be visible through
rake praxis:routes
- the default api prefix pattern is ("/v(version)/") but can changed by either
- overriding `
Praxis::Request.path_version_prefix
and return the appropriate string prefix (i.e., by default this returns "/v") - or overriding
Praxis::Request.path_version_matcher
and providing the fully custom matching regexp. This regexp must have a capture (namedversion
) that would return matched version value.
- overriding `
- version DSL now can take a
- โจ Enhanced praxis generator:
- Added a new generator (available through
praxis new app_name
) which creates a blank new app, with enough basic structure and setup to start building an API. - Changed the example hello world generation command. Instead of
praxis generate app_name
, it is now available throughpraxis example app_name
- Changed the path lookup for the praxis directory (to not use installed gems, which could be multiple). [Issue #67]
- Added a new generator (available through
ResourceDefinition
:- Added:
action_defaults
method, to define default options for actions. May be called more than once. - Removed:
params
,payload
,headers
, andresponse
. Specify these insideaction_defaults
instead.
- Added:
Application
:- Added
middleware
method to use Rack middleware.
- Added
ErrorHandler
- It is now possible to register the error handler class to be invoked when an uncaught exception is thrown by setting
Application#error_handler
. - The default error handler writes the error and backtrace into the Praxis logger, and returns an
InternalServerError
response
- It is now possible to register the error handler class to be invoked when an uncaught exception is thrown by setting
- โ Added
Praxis::Notifications
framework backed by ActiveSupport::Notifications- Its interface is the same as AS::Notifications (.publish, .instrument, .subscribe, and etc.)
- Each incoming rack request is instrumented as
rack.request.all
, with a payload of{response: response}
, whereresponse
is theResponse
object that will be returned to the client. Internally, Praxis subscribes to this to generate timing statistics withPraxis::Stats
. - Additionally, each request that is dispatched to an action is instrumented as
praxis.request.all
, with a payload of{request: request, response: response}
, whereresponse
is as above, andrequest
is theRequest
object for the request.
- โ Added
Praxis::Stats
framework backed byHarness
(i.e. a statsd interface)- Can be configured with a collector type (fake, Statsd) and an asynchronous queue + thread
- Wraps the statsd interface: count, increment, decrement, time ...
- โ Added a new
decorate_docs
method to enhance generated JSON docs for actions inResourceDefinitions
- Using this hook, anybody can register a block that can change/enhance the JSON structure of generated documents for any given action
- โ Added a brand new Plugins architecture
- Plugins can easily inject code in the Request, Controller, ResourceDefinition or ActionDefinition
- Can be instances or singletons (and will be initialized correspondingly)
- Plugins can be easily configured under a unique "config key" in the Praxis config
- See the Plugins section in the documentation for more information.
- โ Added a Plugin for using the Praxis::Mapper gem
- Configurable through a simple
praxis_mapper.yml
file - Its supports several repositories (by name)
- Each repository can be of a different type (default is sequel)
- Configurable through a simple
- ๐ป
praxis:doc_browser
rake task now takes a port argument for specifying the port to run on, e.g.rake praxis:doc_browser[9000]
to run on port 9000. - โ Added
show_exceptions
configuration option to to control default ErrorHandler behavior.