Making RSS feeds using Dancer::Plugin::Feed

RSS is a very popular way to see updates of any site. Many sites use it, and you may well want to add RSS support to your site. You can easily do it with Dancer using Dancer::Plugin::Feed.

Description of common functions

create_feed

This function returns a XML feed. All parameters can be define in the configuration

Accepted parameters are:

format (required)

The Content-Type header will be set to the appropriate value

entries

An arrayref containing a list of entries. Each item will be transformed to an XML::Feed::Entry object. Each entry is an hashref. Some common attributes for these hashrefs are title, link, summary, content, author, issued and modified. Check XML::Feed::Entry for more details.

title

base

link

tagline

description

author

language

copyright

self_link

modified

create_atom_feed

This method calls create_feed, setting the format to Atom.

create_rss_feed

This method calls create_feed, setting the format to RSS.

Simple example

use Dancer; 
use Dancer::Plugin::Feed;

get '/feed/:format' => sub {
  my $feed = create_feed( 
    format => params->{format}, #Feed format (RSS or Atom) 
    title => 'my great feed', 
    entries => [ map { title => "entry $_" }, 1 .. 10 ], #makes collection of feed entries
  );
  return $feed;
};
 dance;

AUTHOR

This article was written by Andrew Inishev, Google Code-In student, mentored by David Precious.