Sha256: 68199df4ffe762a539c39eb2e9e0734986d468ce4362e1f1b5b04c28c1eb4ab4

Contents?: true

Size: 759 Bytes

Versions: 2

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

require("zapp/http_context/request")
require("zapp/http_context/response")

module Zapp
  module HTTPContext
    # Context containing request and response
    class Context
      attr_reader(:req, :res)

      def initialize(socket:)
        @socket = socket
        @req = Zapp::HTTPContext::Request.new(socket: socket)
        @res = Zapp::HTTPContext::Response.new(socket: socket)
      end

      def close
        @socket.close
      end

      def dup
        clone_context = super
        clone_context.instance_variable_set(:@req, @req.dup)
        clone_context.instance_variable_set(:@res, @res.dup)
        clone_context.instance_variable_set(:@socket, @socket.dup)

        clone_context
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zapp-0.1.1 lib/zapp/http_context/context.rb
zapp-0.1.0 lib/zapp/http_context/context.rb