-
Notifications
You must be signed in to change notification settings - Fork 582
Stdlib::Http::Method: Add new type for http methods #1299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Stdlib::Http::Method' do | ||
describe 'valid HTTP Methods' do | ||
[ | ||
'HEAD', | ||
'GET', | ||
'PUT', | ||
'DELETE', | ||
'TRACE', | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.to allow_value(value) } | ||
end | ||
end | ||
end | ||
|
||
describe 'invalid path handling' do | ||
context 'garbage inputs' do | ||
[ | ||
nil, | ||
[nil], | ||
[nil, nil], | ||
{ 'foo' => 'bar' }, | ||
{}, | ||
'', | ||
'https', | ||
'199', | ||
600, | ||
1_000, | ||
'Ok', | ||
'get', | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.not_to allow_value(value) } | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Stdlib::Http::Status' do | ||
describe 'valid HTTP Status' do | ||
[ | ||
200, | ||
302, | ||
404, | ||
418, | ||
503, | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.to allow_value(value) } | ||
end | ||
end | ||
end | ||
|
||
describe 'invalid path handling' do | ||
context 'garbage inputs' do | ||
[ | ||
nil, | ||
[nil], | ||
[nil, nil], | ||
{ 'foo' => 'bar' }, | ||
{}, | ||
'', | ||
'https', | ||
'199', | ||
600, | ||
1_000, | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.not_to allow_value(value) } | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# @summary Valid HTTP method verbs | ||
# @see https://www.iana.org/assignments/http-methods/http-methods.xhtml | ||
type Stdlib::Http::Method = Enum[ | ||
'ACL', | ||
'BASELINE-CONTROL', | ||
'BIND', | ||
'CHECKIN', | ||
'CHECKOUT', | ||
'CONNECT', | ||
'COPY', | ||
'DELETE', | ||
'GET', | ||
'HEAD', | ||
'LABEL', | ||
'LINK', | ||
'LOCK', | ||
'MERGE', | ||
'MKACTIVITY', | ||
'MKCALENDAR', | ||
'MKCOL', | ||
'MKREDIRECTREF', | ||
'MKWORKSPACE', | ||
'MOVE', | ||
'OPTIONS', | ||
'ORDERPATCH', | ||
'PATCH', | ||
'POST', | ||
'PRI', | ||
'PROPFIND', | ||
'PROPPATCH', | ||
'PUT', | ||
'REBIND', | ||
'REPORT', | ||
'SEARCH', | ||
'TRACE', | ||
'UNBIND', | ||
'UNCHECKOUT', | ||
'UNLINK', | ||
'UNLOCK', | ||
'UPDATE', | ||
'UPDATEREDIRECTREF', | ||
'VERSION-CONTROL', | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @summary A valid HTTP status code per RFC9110 | ||
# @see https://httpwg.org/specs/rfc9110.html#overview.of.status.codes | ||
type Stdlib::Http::Status = Integer[100, 599] | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# @summary Validate a HTTP status code | ||
b4ldr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type Stdlib::HttpStatus = Integer[100, 599] | ||
# @deprecated Use Stdlib::Http::Status | ||
# @see Stdlib::Http::Status | ||
type Stdlib::HttpStatus = Stdlib::Http::Status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after this is merged, can you raise a new PR that removes this old type? Then we can keep it open until the next major release and won't forget it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure will do, ill leave this open for now so i dont forget |
Uh oh!
There was an error while loading. Please reload this page.