Sha256: 06da7bb26d553f1537d8a5f9ee6e063ea1544f685f103fbdf5a227f979f15a66

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'reel'
require 'json'

# require 'ruby-prof'
#
# RubyProf.start
# RubyProf.pause

module Angelo

  GET =     'GET'
  POST =    'POST'
  PUT =     'PUT'
  DELETE =  'DELETE'
  OPTIONS = 'OPTIONS'

  ROUTABLE = [:get, :post, :put, :delete, :socket]
  HTTPABLE = [:get, :post, :put, :delete]

  CONTENT_TYPE_HEADER_KEY = 'Content-Type'

  HTML_TYPE = 'text/html'
  JSON_TYPE = 'application/json'
  FORM_TYPE = 'application/x-www-form-urlencoded'

  DEFAULT_ADDR = '127.0.0.1'
  DEFAULT_PORT = 4567

  DEFAULT_RESPONSE_HEADERS = {
    CONTENT_TYPE_HEADER_KEY => HTML_TYPE
  }

  NOT_FOUND = 'Not Found'

  LOG_FORMAT = '%s - - "%s %s%s HTTP/%s" %d %s'

  def self.log connection, request, socket, status, body_size = '-'
    Celluloid::Logger.debug LOG_FORMAT % [
      socket.nil? ? connection.remote_ip : socket.peeraddr(false)[3],
      request.method,
      request.path,
      request.query_string.nil? ? nil : '?'+request.query_string,
      request.version,
      Symbol === status ? HTTP::Response::SYMBOL_TO_STATUS_CODE[status] : status,
      body_size
    ]
  end

end

require 'angelo/version'
require 'angelo/params_parser'
require 'angelo/server'
require 'angelo/base'
require 'angelo/responder'
require 'angelo/responder/websocket'

# trap "INT" do
#   result = RubyProf.stop
#   printer = RubyProf::MultiPrinter.new(result)
#   printer.print(path: './profiler', profile: 'foo')
#   exit
# end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
angelo-0.1.0 lib/angelo.rb