Class: Mayak::Http::Request
- Inherits:
-
T::Struct
- Object
- T::Struct
- Mayak::Http::Request
- Extended by:
- T::Sig
- Defined in:
- lib/mayak/http/request.rb
Constant Summary collapse
- CONTENT_TYPE_HEADER =
T.let("Content-Type", String)
Class Method Summary collapse
- .delete(url:, headers: {}, body: nil) ⇒ Object
- .get(url:, headers: {}, body: nil) ⇒ Object
- .head(url:, headers: {}, body: nil) ⇒ Object
- .patch(url:, headers: {}, body: nil) ⇒ Object
- .post(url:, headers: {}, body: nil) ⇒ Object
- .put(url:, headers: {}, body: nil) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #content_type ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #with_content_type(type) ⇒ Object
Class Method Details
.delete(url:, headers: {}, body: nil) ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/mayak/http/request.rb', line 100 def self.delete(url:, headers: {}, body: nil) Mayak::Http::Request.new( verb: Mayak::Http::Verb::Delete, url: url, headers: headers, body: body ) end |
.get(url:, headers: {}, body: nil) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/mayak/http/request.rb', line 50 def self.get(url:, headers: {}, body: nil) Mayak::Http::Request.new( verb: Mayak::Http::Verb::Get, url: url, headers: headers, body: body ) end |
.head(url:, headers: {}, body: nil) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/mayak/http/request.rb', line 60 def self.head(url:, headers: {}, body: nil) Mayak::Http::Request.new( verb: Mayak::Http::Verb::Head, url: url, headers: headers, body: body ) end |
.patch(url:, headers: {}, body: nil) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/mayak/http/request.rb', line 90 def self.patch(url:, headers: {}, body: nil) Mayak::Http::Request.new( verb: Mayak::Http::Verb::Patch, url: url, headers: headers, body: body ) end |
Instance Method Details
#==(other) ⇒ Object
20 21 22 |
# File 'lib/mayak/http/request.rb', line 20 def ==(other) verb == other.verb && url.to_s == other.url.to_s && headers == other.headers && body == other.body end |
#content_type ⇒ Object
35 36 37 |
# File 'lib/mayak/http/request.rb', line 35 def content_type headers[CONTENT_TYPE_HEADER] end |
#eql?(other) ⇒ Boolean
25 26 27 |
# File 'lib/mayak/http/request.rb', line 25 def eql?(other) self == other end |
#hash ⇒ Object
30 31 32 |
# File 'lib/mayak/http/request.rb', line 30 def hash [verb, url.to_s, headers, body].hash end |
#with_content_type(type) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/mayak/http/request.rb', line 40 def with_content_type(type) Mayak::Http::Request.new( verb: verb, url: url, headers: headers.merge(CONTENT_TYPE_HEADER => type), body: body ) end |