Sha256: 5a13ef88c5feebdea1c724f4ba7cb0b6d7f3283be0254e2f4d7fa0661c6d94a9

Contents?: true

Size: 1.49 KB

Versions: 11

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

PUNK::Command.create "GET" do
  description "Perform a HTTP GET request"

  def process
    path, query = args[0].split('?')
    PUNK.app.call(
      "REQUEST_METHOD" => "GET",
      "PATH_INFO" => path,
      "QUERY_STRING" => query,
      "SCRIPT_NAME" => "",
      "rack.input" => StringIO.new
    )
  end
end

PUNK::Command.create "PATCH" do
  description "Perform a HTTP PATCH request"

  def process
    PUNK.app.call(
      "REQUEST_METHOD" => "PATCH",
      "PATH_INFO" => args[0],
      "CONTENT_TYPE" => "text/json",
      "SCRIPT_NAME" => "",
      "rack.input" => StringIO.new(args[1..-1].join)
    )
  end
end

PUNK::Command.create "POST" do
  description "Perform a HTTP POST request"

  def process
    PUNK.app.call(
      "REQUEST_METHOD" => "POST",
      "PATH_INFO" => args[0],
      "CONTENT_TYPE" => "text/json",
      "SCRIPT_NAME" => "",
      "rack.input" => StringIO.new(args[1..-1].join)
    )
  end
end

PUNK::Command.create "PUT" do
  description "Perform a HTTP PUT request"

  def process
    PUNK.app.call(
      "REQUEST_METHOD" => "PUT",
      "PATH_INFO" => args[0],
      "CONTENT_TYPE" => "text/json",
      "SCRIPT_NAME" => "",
      "rack.input" => StringIO.new(args[1..-1].join)
    )
  end
end

PUNK::Command.create "DELETE" do
  description "Perform a HTTP DELETE request"

  def process
    PUNK.app.call(
      "REQUEST_METHOD" => "DELETE",
      "PATH_INFO" => args[0],
      "SCRIPT_NAME" => "",
      "rack.input" => StringIO.new
    )
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
punk-0.3.6 lib/punk/commands/http.rb
punk-0.3.5 lib/punk/commands/http.rb
punk-0.3.4 lib/punk/commands/http.rb
punk-0.3.3 lib/punk/commands/http.rb
punk-0.3.2 lib/punk/commands/http.rb
punk-0.3.1 lib/punk/commands/http.rb
punk-0.2.0 lib/punk/commands/http.rb
punk-0.1.4 lib/punk/commands/http.rb
punk-0.1.3 lib/punk/commands/http.rb
punk-0.1.2 lib/punk/commands/http.rb
punk-0.1.0 lib/punk/commands/http.rb