app/server.rb in sqlui-0.1.31 vs app/server.rb in sqlui-0.1.32

- old
+ new

@@ -38,18 +38,18 @@ end get "#{database.url_path}/sqlui.css" do @css ||= File.read(File.join(resources_dir, 'sqlui.css')) status 200 - headers 'Content-Type' => 'text/css' + headers 'Content-Type' => 'text/css; charset=utf-8' body @css end get "#{database.url_path}/sqlui.js" do @js ||= File.read(File.join(resources_dir, 'sqlui.js')) status 200 - headers 'Content-Type' => 'text/javascript' + headers 'Content-Type' => 'text/javascript; charset=utf-8' body @js end post "#{database.url_path}/metadata" do metadata = database.with_client do |client| @@ -74,11 +74,11 @@ ] end } end status 200 - headers 'Content-Type' => 'application/json' + headers 'Content-Type' => 'application/json; charset=utf-8' body metadata.to_json end post "#{database.url_path}/query" do params.merge!(JSON.parse(request.body.read, symbolize_names: true)) @@ -115,27 +115,26 @@ result[:selection] = params[:selection] result[:query] = full_sql status 200 - headers 'Content-Type' => 'application/json' + headers 'Content-Type' => 'application/json; charset=utf-8' body result.to_json end get(%r{#{Regexp.escape(database.url_path)}/(query|graph|structure|saved)}) do @html ||= File.read(File.join(resources_dir, 'sqlui.html')) status 200 - headers 'Content-Type' => 'text/html' + headers 'Content-Type' => 'text/html; charset=utf-8' body @html end end error do |e| status 500 - headers 'Content-Type' => 'application/json' + headers 'Content-Type' => 'application/json; charset=utf-8' message = e.message.lines.first&.strip || 'unexpected error' - message = "#{message[0..80]}…" if message.length > 80 result = { error: message, stacktrace: e.backtrace.map { |b| b }.join("\n") } body result.to_json @@ -146,10 +145,10 @@ private def client_error(message, stacktrace: nil) status(400) - headers 'Content-Type' => 'application/json' + headers 'Content-Type' => 'application/json; charset=utf-8' body({ error: message, stacktrace: stacktrace }.compact.to_json) end def execute_query(client, sql) queries = if sql.include?(';')