Module: HttpStub::Server::Application::Routes::Session

Included in:
Application
Defined in:
lib/http_stub/server/application/routes/session.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(application) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/http_stub/server/application/routes/session.rb', line 13

def self.included(application)
  application.instance_eval do

    namespace "/http_stub" do

      get do
        redirect settings.session_identifier? ? "/http_stub/sessions" : "/http_stub/sessions/transactional"
      end

      namespace "/sessions" do

        get "/transactional" do
          haml :transactional_session, {}, session: @session_controller.find_transactional(logger)
        end

        get do
          pass unless http_stub_request.session_id
          haml :session, {}, session: @session_controller.find(http_stub_request, logger)
        end

        get do
          haml :sessions, {}, sessions: @session_controller.find_all
        end

        delete do
          pass unless http_stub_request.session_id
          @session_controller.delete(http_stub_request, logger)
          halt 200, "OK"
        end

        delete do
          @session_controller.clear(logger)
          halt 200, "OK"
        end

      end

    end

  end
end

Instance Method Details

#initializeObject


8
9
10
11
# File 'lib/http_stub/server/application/routes/session.rb', line 8

def initialize
  super()
  @session_controller = HttpStub::Server::Session::Controller.new(@server_memory)
end