Skip to content

Commit

Permalink
Add Unauthorized response template
Browse files Browse the repository at this point in the history
  • Loading branch information
aldesantis committed Jan 31, 2018
1 parent 51982fb commit 0446948
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Added `Unauthorized` response template

## [2.0.0]

First Pragma 2 release.
Expand Down
1 change: 1 addition & 0 deletions lib/pragma/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require 'pragma/operation/response/created'
require 'pragma/operation/response/ok'
require 'pragma/operation/response/no_content'
require 'pragma/operation/response/unauthorized'

module Pragma
# Operations provide business logic encapsulation for your JSON API.
Expand Down
19 changes: 19 additions & 0 deletions lib/pragma/operation/response/unauthorized.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Pragma
module Operation
class Response
class Unauthorized < Response
def initialize(
entity: Error.new(
error_type: :unauthorized,
error_message: 'This resource requires authentication.',
),
headers: {}
)
super(status: 401, entity: entity, headers: headers)
end
end
end
end
end

0 comments on commit 0446948

Please sign in to comment.