Sha256: 8b7fdb1013b55c291f0b7e5a58165ed29b592eebe02cfbe0a6ddcbda8a1799a5
Contents?: true
Size: 928 Bytes
Versions: 7
Compression:
Stored size: 928 Bytes
Contents
require 'saorin/server/base' require 'rack' module Saorin module Server class Rack include Base DEFAULT_HEADERS = { 'Content-Type' => 'application/json' }.freeze attr_reader :server def initialize(handler, options = {}) super @server = ::Rack::Server.new({ :app => self, :Host => options[:host], :Port => options[:port], }.merge(@options)) end def start(&block) @server.start &block end def shutdown if @server.server.respond_to?(:shutdown) @server.server.shutdown end end def call(env) request = ::Rack::Request.new(env) response = ::Rack::Response.new([], 200, DEFAULT_HEADERS.dup) response.write process_request(request.body.read) if request.post? response.finish end end register :rack, Rack end end
Version data entries
7 entries across 7 versions & 1 rubygems