Module: Angelo

Defined in:
lib/angelo.rb,
lib/angelo/base.rb,
lib/angelo/stash.rb,
lib/angelo/server.rb,
lib/angelo/version.rb,
lib/angelo/tilt/erb.rb,
lib/angelo/responder.rb,
lib/angelo/mustermann.rb,
lib/angelo/params_parser.rb,
lib/angelo/minitest/helpers.rb,
lib/angelo/responder/websocket.rb

Overview

require ‘ruby-prof’

RubyProf.start RubyProf.pause

Defined Under Namespace

Modules: Minitest, Mustermann, ParamsParser, Tilt Classes: Base, FormEncodingError, HALT_STRUCT, RequestError, Responder, Server, Stash, WebsocketResponder

Constant Summary collapse

GET =
'GET'
POST =
'POST'
PUT =
'PUT'
DELETE =
'DELETE'
OPTIONS =
'OPTIONS'
ROUTABLE =
[:get, :post, :put, :delete, :websocket]
HTTPABLE =
[:get, :post, :put, :delete]
STATICABLE =
[:get, :head]
CONTENT_TYPE_HEADER_KEY =
'Content-Type'
CONTENT_DISPOSITION_HEADER_KEY =
'Content-Disposition'
CONTENT_LENGTH_HEADER_KEY =
'Content-Length'
DEFAULT_CONTENT_DISPOSITION =
'attachment'
ETAG_HEADER_KEY =
'ETag'
IF_NONE_MATCH_HEADER_KEY =
'If-None-Match'
LOCATION_HEADER_KEY =
'Location'
HTML_TYPE =
'text/html'
JSON_TYPE =
'application/json'
FORM_TYPE =
'application/x-www-form-urlencoded'
FILE_TYPE =
'application/octet-stream'
DEFAULT_ADDR =
'127.0.0.1'
DEFAULT_PORT =
4567
DEFAULT_VIEW_DIR =
'views'
DEFAULT_PUBLIC_DIR =
'public'
DEFAULT_RESPONSE_HEADERS =
{
  CONTENT_TYPE_HEADER_KEY => HTML_TYPE
}
NOT_FOUND =
'Not Found'
LOG_FORMAT =
'%s - - "%s %s%s HTTP/%s" %d %s'
DEFAULT_PING_TIME =
30
UNDERSCORE =
'_'
DASH =
'-'
EMPTY_STRING =
''
VERSION =
'0.1.11'

Class Method Summary collapse

Class Method Details

.log(connection, request, socket, status, body_size = '-') ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/angelo.rb', line 56

def self.log connection, request, socket, status, body_size = '-'

  remote_ip = ->{
    if socket.nil?
      connection.remote_ip rescue 'unknown'
    else
      socket.peeraddr(false)[3]
    end
  }

  Celluloid::Logger.debug LOG_FORMAT % [
    remote_ip[],
    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