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.28 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.27 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.26 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.25 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.24 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.23 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.22 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.21 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.20 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.19 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.18 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.17 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.16 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.15 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.14 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.13 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.12 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.11 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.10 lib/opener/chained_daemon/webservice.rb
opener-chained-daemon-3.3.9 lib/opener/chained_daemon/webservice.rb