Class: Anmo::Application
- Inherits:
-
Object
- Object
- Anmo::Application
- Defined in:
- lib/anmo/application.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
69 70 71 72 |
# File 'lib/anmo/application.rb', line 69 def initialize ApplicationDataStore.clear_objects ApplicationDataStore.clear_requests end |
Instance Method Details
#call(env) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/anmo/application.rb', line 74 def call(env) request = Rack::Request.new(env) if request.path_info =~ /^\/status$/ return [200, {}, "ok"] end if request.request_method.upcase == "OPTIONS" return [ 200, { "Access-Control-Allow-Origin" => "*", "Access-Control-Allow-Methods" => "*", "Access-Control-Allow-Headers" => "X-Requested-With,Content-Type,Authorization" }, "" ] end controller_methods = [ :alive, :version, :create_object, :objects, :requests, :delete_all_objects, :delete_all_requests ] method = controller_methods.find { |m| request.path_info =~ /\/?__#{m.to_s.upcase}__\/?/ } method ||= :process_normal_request send(method, request) end |