Sha256: 93272cee77b64bc9c6e009fbf670de6b6c497edf6415275087ff5f69c758fc12

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 Bytes

Contents

require 'sinatra/base'
require 'sinatra/reloader' if ENV['RUBYPITAYA_ENV'] == 'development'
require 'rubypitaya/core/parameters'

module RubyPitaya

  class HttpRoutes < Sinatra::Base

    if ENV['RUBYPITAYA_ENV'] == 'development'
      register Sinatra::Reloader
    end

    helpers do
      def find_template(views, name, engine, &block)
        views.each { |v| super(v, name, engine, &block) }
      end
    end

    before do
      content_type :json

      @bll = settings.bll
      @setup = settings.setup
      @config = settings.config

      if request.content_type == 'aplication/json'
        request_body = request.body.read
        @params.merge!(JSON.parse(request_body)) if !request_body.blank?
      end

      @params = Parameters.new(@params)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubypitaya-2.7.0 ./lib/rubypitaya/core/http_routes.rb
rubypitaya-2.6.4 ./lib/rubypitaya/core/http_routes.rb