Class: Murlsh::PodcastServer

Inherits:
Server
  • Object
show all
Defined in:
lib/murlsh/podcast_server.rb

Overview

Serve podcast RSS feed.

Instance Attribute Summary

Attributes inherited from Server

#config

Instance Method Summary collapse

Methods inherited from Server

#initialize

Constructor Details

This class inherits a constructor from Murlsh::Server

Instance Method Details

#get(req) ⇒ Object

Respond to a GET request for podcast RSS feed.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/murlsh/podcast_server.rb', line 13

def get(req)
  page = 1
  per_page = config.fetch('num_posts_feed', 25)

  result_set = Murlsh::UrlResultSet.new(req['q'], page, per_page,
    :content_type => 'audio/mpeg')

  feed_url = URI.join(config.fetch('root_url'), 'podcast.rss')
  body = Murlsh::RssBody.new(config, req, feed_url, result_set.results)

  resp = Rack::Response.new(body, 200,
    'Content-Type' => 'application/rss+xml')
  if u = body.updated
    resp['Last-Modified'] = u.httpdate
  end
  resp
end