Did the before filter change in version 2 of the Sinatra gem?

Viewed 27

I am in the process of upgrading a Rails application from Ruby 2.5.8 to 2.7.4 and Rails 4.2.8 to 5.2.6. The sinatra gem used by webservices it provides is updating from 1.4.8 to 2.1.0.

The content type observed in the webservice responses has changes from application/json in the old branch to text/html in the new Rails 5.2 branch.

We have a base webservice class PmoWebservice that declares the content_type like this:

class PmoWebservice < Sinatra::Base

  before do
    content_type :json, :charset => 'utf-8'
  end

And this class is inherited by each webservice, for example:

class FinalDeliverableProjectWebservice < PmoWebservice

I can get the content type to be application/json again in the responses if I declare it in individual methods, but that before filter is no longer working. For example, this restores the correct response content type header:

  get '/pmo_webservices/final_deliverable_project/:id' do
    content_type 'application/json'
< HTTP/1.1 200 OK
< Content-Type: application/json

So has something changed in the way to declare a content type for all URL handling methods in Sinatra? Or the inheritance of before do ... end filters?

0 Answers
Related