Sha256: 8617068c8a19d4a7404b7617d296989247e155ea60656b36b315ee9a3f86b648

Contents?: true

Size: 619 Bytes

Versions: 39

Compression:

Stored size: 619 Bytes

Contents

require 'roda'

module Opener
  class ChainedDaemon
    class Webservice < Roda

      TOKEN = ENV['PRIVATE_TOKEN']

      class_attribute :processor
      self.processor = ChainedDaemon.new

      route do |r|
        response.status = 403 and r.halt if r.params['auth_token'] != TOKEN

        sentiment = -> do
          r.params.deep_symbolize_keys!
          kaf = processor.run r.params[:input], **r.params.except(:input)

          response['Content-Type'] = 'text/xml'
          kaf
        end

        r.get  'sentiment.kaf', &sentiment
        r.post 'sentiment.kaf', &sentiment
      end

    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
opener-chained-daemon-3.3.8 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.7 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.6 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.5 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.4 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.3 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.2 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.1 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.0 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.2.0 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.1.5 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.1.4 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.1.3 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.1.2 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.1.1 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.1.0 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.0.7 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.0.6 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.0.5 lib/opener/chained_daemon/webservice.rb