The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Jifty::Plugin::REST::Dispatcher - Dispatcher for REST plugin

show_help

Shows basic help about resources and formats available via this RESTful interface.

show_help_specific

Displays a help page about a specific topic. Will look for a method named show_help_specific_$1.

Explains /=/search/ a bit more in-depth.

show_version

Displays versions of the various bits of your application.

list PREFIX items

Takes a URL prefix and a set of items to render. passes them on.

output_format [prefix]

Returns the user's desired output format. Returns a hashref of:

    format: JSON, JS, YAML, XML, Perl, or HTML
    extension: json, js, yml, xml, pl, or html
    content_type: text/x-yaml; charset=UTF-8, etc.
    freezer: \&Jifty::YAML::Dump, etc.

outs PREFIX DATASTRUCTURE

Takes a url path prefix and a data structure. Depending on what content types the other side of the HTTP connection can accept, renders the content as YAML, JSON, JavaScript, Perl, XML or HTML.

render_as_xml DATASTRUCTURE

Attempts to render DATASTRUCTURE as simple, tag-based XML.

render_as_html PREFIX URL DATASTRUCTURE

Attempts to render DATASTRUCTURE as simple semantic HTML suitable for humans to look at.

html_dump DATASTRUCTURE

Recursively render DATASTRUCTURE as some simple HTML dls and ols.

html_dump_record Jifty::Record

Returns a nice simple HTML definition list of the keys and values of a Jifty::Record object.

action ACTION

Canonicalizes ACTION into the class-name form preferred by Jifty by cleaning up casing, delimiters, etc. Throws an appropriate HTTP error code if the action is unavailable.

model MODEL

Canonicalizes MODEL into the class-name form preferred by Jifty by cleaning up casing, delimiters, etc. Throws an appropriate HTTP error code if the model is unavailable.

list_models

Sends the user a list of models in this application, with the names transformed from Perlish::Syntax to Everything.Else.Syntax

valid_column

Returns true if the column is a valid column to observe on the model

list_model_columns

Sends the user a nice list of all columns in a given model class. Exactly which model is shoved into $1 by the dispatcher. This should probably be improved.

list_model_items MODELCLASS COLUMNNAME

Returns a list of items in MODELCLASS sorted by COLUMNNAME, with only COLUMNNAME displayed. (This should have some limiting thrown in)

show_item_field $model, $column, $key, $field

Loads up a model of type $model which has a column $column with a value $key. Returns the value of $field for that object. Returns 404 if it doesn't exist.

show_item $model, $column, $key

Loads up a model of type $model which has a column $column with a value $key. Returns all columns for the object

Returns 404 if it doesn't exist.

search_items $model, [c1, v1, c2, v2, ...] [, $field]

Loads up all models of type $model that match the given columns and values. If the column and value list has an odd count, then the last item is taken to be the output column. Otherwise, all items will be returned.

Will throw a 404 if there were no matches, or $field was invalid.

Pseudo-columns:

__per_page => N

Return the collection as N records per page.

__page => N

Return page N of the collection

__order_by => column

Order by the given column, ascending.

__order_by_desc => column

Order by the given column, descending.

create_item

Implemented by redispatching to a CreateModel action.

replace_item

Implemented by redispatching to a CreateModel or UpdateModel action.

replace_item_field $model, $column, $key, $field

Loads up a model of type $model which has a column $column with a value $key. Sets the value of the field based on the request payload. Returns 404 if it doesn't exist.

delete_item

Implemented by redispatching to a DeleteModel action.

list_actions

Returns a list of all actions visible to the current user. (Canonicalizes Perl::Style to Everything.Else.Style).

list_action_params

Takes a single parameter, $action, supplied by the dispatcher.

Shows the user all possible parameters to the action.

show_action_form $ACTION_CLASS

Takes a single parameter, the class of an action.

Shows the user an HTML form of the action's parameters to run that action.

run_action

Expects $1 to be the name of an action we want to run.

Runs the action, with the HTTP arguments as its arguments. That is, it's not looking for Jifty-encoded (J:F) arguments. If you have an action called "MyApp::Action::Ping" that takes a parameter, ip, this action will look for an HTTP argument called ip, (not J:F-myaction-ip).

Returns the action's result.

TODO, doc the format of the result.

On an invalid action name, throws a 404. On a disallowed action name, throws a 403. On an internal error, throws a 500.