---
name: "Jifty::Plugin::REST::Dispatcher"
section: "3pm"
platform: "linux"
package: "libjifty-perl"
version: "1.10518+dfsg-2"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/Jifty::Plugin::REST::Dispatcher"
---

# Jifty::Plugin::REST::Dispatcher(3pm)

Dispatcher for REST plugin

## 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"`.

### show\_help\_specific\_search

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 `"dl"`s and `"ol"`s.

### 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.

### 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`.
