I have a basic Sinatra app, I'd like to serve a yaml
file so that it can be read by a gem via http.
I'm just able to download it:
get '/download' do
send_file './en.yml', :filename => 'en.yml', :type => 'text/yaml'
end
But how can I just serve it without downloading?
Goal is that a gem makes an http request to obtain the content of this endpoint.
CodePudding user response:
Any reason you can't convert the YAML to JSON and serve that?
require 'json'
require 'sinatra'
require 'sinatra/json' # from sinatra-contrib
require 'yaml'
get '/download' do
json YAML.safe_load(File.read('en.yml'))
end