Sha256: 43d24160b6ee8eebe26a3028b091743a4cd0c5d8422c1422bf9d955dd2e5ae6b

Contents?: true

Size: 417 Bytes

Versions: 5

Compression:

Stored size: 417 Bytes

Contents

class ::Simple::Httpd::BaseController
  helpers do
    # encodes the result, according to its payload.
    #
    # This function is used by the service integration code, but
    # is potentially useful outside.
    def encode_result(result)
      case result
      when Array, Hash
        json(result)
      when String
        content_type :text
        result
      else
        result
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple-httpd-0.4.3 lib/simple/httpd/base_controller/result.rb
simple-httpd-0.4.2 lib/simple/httpd/base_controller/result.rb
simple-httpd-0.4.1 lib/simple/httpd/base_controller/result.rb
simple-httpd-0.4.0 lib/simple/httpd/base_controller/result.rb
simple-httpd-0.3.5 lib/simple/httpd/base_controller/result.rb