abril / tokamak

template engine for hypermedia resources that provides a single DSL to generate several media types representations
Other
39 stars 11 forks source link

Custom mime-types for default builders #8

Closed nbaksalyar closed 13 years ago

nbaksalyar commented 13 years ago

Now if using Rails+Restfulie you'll define a custom app XML mimetype in config\initializers\mime_types.rb, such as:

Mime::Type.register "application/vnd.foobar+xml", :xml

you'll get an error, since Tokamak standard builders - e.g., Tokamak::Builder::Xml, is depending on a standard mimetypes (application/xml & text/xml in this case). So at present moment in order to use custom mimetypes monkey-patching is required:

Tokamak::Builder::Xml.class_eval do
  builder_for "application/vnd.foobar+xml"
end

I suggest the workaround is to define a method like "add_mimetype":

Tokamak::Builder::Xml.add_mimetype "application/vnd.foobar+xml"
lfcipriani commented 13 years ago

Yeah, you're right

Done with the commit https://github.com/abril/tokamak/commit/7093eed54d8811c95d2654b34014418630581d72