def resource_exists? page end def content_types_accepted [['application/json', :from_json]] end def content_types_provided [['text/html', :as_html]] end def from_json params = JSON.parse(request.body.to_s) redis.set id, "<head><title>#{params['title']}</title></head><body>#{params['body']}</ body>" end def as_html page end private def page @page ||= redis.get id end def id request.path_info[:id] end end