-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add authorization methods to OSS
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module PactBroker | ||
module Api | ||
module Resources | ||
module Authorization | ||
def action | ||
if read_methods.include?(request.method) | ||
:read | ||
elsif update_methods.include?(request.method) | ||
:update | ||
elsif create_methods.include?(request.method) | ||
:create | ||
elsif delete_methods.include?(request.method) | ||
:delete | ||
else | ||
raise "Cannot map #{request.method} to an action" | ||
end | ||
end | ||
|
||
def read_methods | ||
%w{GET HEAD OPTIONS} | ||
end | ||
|
||
def update_methods | ||
%w{PUT PATCH} | ||
end | ||
|
||
def create_methods | ||
%w{POST PUT} | ||
end | ||
|
||
def delete_methods | ||
%w{DELETE} | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters