Sha256: 1cc7a29239ade8a04361b26a86805b073948a6e6939f383c31bde1284018f675

Contents?: true

Size: 793 Bytes

Versions: 85

Compression:

Stored size: 793 Bytes

Contents

class Brief::Server
  attr_reader :options, :briefcase

  def initialize(briefcase, options={})
    @briefcase = briefcase
    @options = options
  end

  def call(env)
    request = Brief::Server::Route.new(env, briefcase, options)
    status, headers, body = request.respond()

    body = body.to_json if body.is_a?(Hash)
    body = body.to_json if body.is_a?(Array)
    body = body.as_json.to_json if body.is_a?(Brief::Model)

    body = "" if body.nil?

    headers["Content-Length"]                 = Rack::Utils.bytesize(body).to_s
    headers["Access-Control-Allow-Origin"]    = "*"
    headers["Access-Control-Allow-Methods"]   = "GET, POST, PUT"
    headers["X-BRIEF-HANDLER"] = request.send(:handler).try(:to_s)

    [status, headers, [body]]
  end
end

require 'brief/server/route'

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
brief-1.17.14 lib/brief/server.rb
brief-1.17.13 lib/brief/server.rb
brief-1.17.12 lib/brief/server.rb
brief-1.17.11 lib/brief/server.rb
brief-1.17.10 lib/brief/server.rb
brief-1.17.9 lib/brief/server.rb
brief-1.17.8 lib/brief/server.rb
brief-1.17.7 lib/brief/server.rb
brief-1.17.5 lib/brief/server.rb
brief-1.17.4 lib/brief/server.rb
brief-1.17.3 lib/brief/server.rb
brief-1.17.2 lib/brief/server.rb
brief-1.17.1 lib/brief/server.rb
brief-1.17.0 lib/brief/server.rb
brief-1.16.2 lib/brief/server.rb
brief-1.16.1 lib/brief/server.rb
brief-1.16.0 lib/brief/server.rb
brief-1.15.5 lib/brief/server.rb
brief-1.15.4 lib/brief/server.rb
brief-1.15.3 lib/brief/server.rb