Seems fair
On May 11, 2013 12:05 AM, "Jack Chu" <notifications@github.com> wrote:

> In templates/lib/hooks.rb:
>
> > @@ -45,6 +51,21 @@ module WDSinatraHooks
> >    #
> >    # Implementation example
> >    def pre_dispatch_hook
> > +    # content negotiation
> > +    accept = env["rack-accept.request"]
> > +    if accept
> > +      service_media_types = SUPPORTED_MEDIA_TYPES.select {|k,v| service.formats.include?(v)}
> > +      env["wd.media_type"] = accept.media_type.best_of(service_media_types.keys)
> > +      halt 406 unless env["wd.media_type"]
> > +      env["wd.format"] =  SUPPORTED_MEDIA_TYPES[env["wd.media_type"]]
> > +    else
> > +      env["wd.media_type"] = "*/*"
> > +      env["wd.format"] =  service.formats.first
> > +      halt 406 unless env["wd.format"] # 406 if no defined service.formats
>
> I'm not sure about defaulting to json. What if the service implementation
> can't handle or doesn't return json? The content type would be set to
> application/json, but it could return a different format.
>
> Not defining a service.formats should raise an exception if it's a
> developer error, otherwise, I kind of think 406 makes sense. The media type
> specified didn't match any supported media type because none was defined.
> Also, a 406 is what you would get if you didn't specify service.formatsbut included an Accept header.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/mattetti/wd-sinatra/pull/30/files#r4180377>
> .
>