Skip to content

Commit

Permalink
HTTP verbs should be namespaced
Browse files Browse the repository at this point in the history
  • Loading branch information
robmiller committed Aug 20, 2013
1 parent c7abf4b commit f61c3c2
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions lib/varnisher/purger.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# Adds the custom verb "PURGE" to the Net::HTTP library, allowing calls
# to:
#
# Net::HTTP.new(host, port).request(Purge.new(uri))
class Purge < Net::HTTPRequest
METHOD = "PURGE"
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = false
end
module Varnisher
module HTTP
# Adds the custom verb "PURGE" to the Net::HTTP library, allowing calls
# to:
#
# Net::HTTP.new(host, port).request(Varnisher::HTTP::Purge.new(uri))
class Purge < Net::HTTPRequest
METHOD = "PURGE"
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = false
end

# Adds the custom verb "DOMAINPURGE" to the Net::HTTP library, allowing
# calls to:
#
# Net::HTTP.new(host, port).request(DomainPurge.new(uri))
class DomainPurge < Net::HTTPRequest
METHOD = "DOMAINPURGE"
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = false
# Adds the custom verb "DOMAINPURGE" to the Net::HTTP library, allowing
# calls to:
#
# Net::HTTP.new(host, port).request(Varnisher::HTTP::DomainPurge.new(uri))
class DomainPurge < Net::HTTPRequest
METHOD = "DOMAINPURGE"
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = false
end
end
end

module Varnisher
Expand Down Expand Up @@ -54,7 +58,7 @@ class Purger
# use "/"
# @param host [String] The hostname of the URL being purged
def initialize(method, path, host)
@request_method = method == "PURGE" ? Purge : DomainPurge
@request_method = method == "PURGE" ? Varnisher::HTTP::Purge : Varnisher::HTTP::DomainPurge
@path = path
@host = host
end
Expand Down

0 comments on commit f61c3c2

Please sign in to comment.