Module: Strelka::App::RestResources

Extended by:
Plugin
Defined in:
lib/strelka/app/restresources.rb

Overview

RESTful resource utilities for Strelka::App.

This plugin allows you to automatically set up RESTful service resources for Sequel::Model-derived classes.

For example, if you have a model class called ACME::Customer for tracking customer data, you can set up a RESTful resource in your Strelka app like this:

require 'strelka'
require 'acme/customer'

class ACME::RestServices < Strelka::App
    plugins :restresources
    resource ACME::Customer
end

Assuming the primary key for customers is a column called 'id', this will install the following routes:

options 'customers'
get 'customers'
get 'customers/:id'
post 'customers'
post 'customers/:id'
put 'customers'
put 'customers/:id'
delete 'customers'
delete 'customers/:id'

The restresources plugin depends on the routing, negotiation, and parameters plugins, and will load them automatically if they haven't been already.

Goals:

[√] Composite resources generated from associations [ ] Honor If-unmodified-since and If-match headers [ ] Support the 'fields' parameter for GET /collection [ ] Support reverse-ordering (via '-fieldname'?) [ ] Caching support (ETag, If-modified-since) [ ] Means of tailoring responses for requests for which the response isn't clearly specified in the RFC (DELETE /resource) [ ] Sequel plugin for adding links to serialized representations

Supported/Planned Options

The 'resource' directive accepts options that control which methods it creates for the specified resource:

[√] :readonly => false [ ] :include => [ ] :exclude => [ ] :filters => [ ] :associations => [ ] :composite =<

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

DEFAULTS =

Resource route option defaults

{
	prefix:           nil,
	name:             nil,
	readonly:         false,
	use_transactions: true,
	composite:        true
}.freeze

Instance Attribute Summary

Attributes included from Plugin

#pluggable, #successors

Instance Method Summary collapse

Methods included from Plugin

extended, plugin_name, run_inside, run_outside

Instance Method Details

#handle_requestObject

This is just here for logging.



666
667
668
669
# File 'lib/strelka/app/restresources.rb', line 666

def handle_request( * ) # :nodoc:
	self.log.debug "[:restresources] handling request for REST resource."
	super
end