lib/nyara/controller.rb in nyara-0.0.1.pre vs lib/nyara/controller.rb in nyara-0.0.1.pre.1
- old
+ new
@@ -12,22 +12,22 @@
@used_ids = {}
action = RouteEntry.new
action.http_method = HTTP_METHODS[method]
action.path = path
- action.set_accept_exts @accept
+ action.set_accept_exts @formats
action.id = @curr_id.to_sym if @curr_id
action.blk = blk
@route_entries << action
if @curr_id
raise ArgumentError, "action id #{@curr_id} already in use" if @used_ids[@curr_id]
@used_ids[@curr_id] = true
@curr_id = nil
@meta_exist = nil
end
- @accept = nil
+ @formats = nil
end
# Set meta data for next action
def meta tag=nil, opts=nil
if @meta_exist
@@ -48,11 +48,11 @@
@curr_id = id
end
if opts
# todo add opts: strong param, etag, cache-control
- @accept = opts[:accept]
+ @formats = opts[:formats]
end
@meta_exist = true
end
@@ -165,12 +165,12 @@
host ||= 'localhost'
path = path_for id, *args, opts
scheme << host << path
end
- def matched_accept
- request.matched_accept
+ def format
+ request.format
end
def header
request.header
end
@@ -242,10 +242,11 @@
header.aset_content_type \
r.response_content_type ||
header.aref_content_type ||
(r.accept and MIME_TYPES[r.accept]) ||
- template_deduced_content_type
+ template_deduced_content_type ||
+ 'text/html'
header.reverse_merge! OK_RESP_HEADER
data = header.map do |k, v|
"#{k}: #{v}\r\n"