class LittleGhost::Network::Decision
Trusted authorization result and tightly scoped upstream header changes.
Public Class Methods
# File lib/little_ghost/network.rb, line 29 def self.allow(set_headers: {}, remove_headers: []) new(allowed: true, status: 200, reason: nil, set_headers:, remove_headers:) end
Allows a request and optionally changes its upstream headers.
# File lib/little_ghost/network.rb, line 34 def self.deny(status: 403, reason: nil) new(allowed: false, status:, reason:, set_headers: {}, remove_headers: []) end
Rejects a request with an HTTP status and optional safe reason.
# File lib/little_ghost/network.rb, line 39 def initialize(allowed:, status:, reason: nil, set_headers: {}, remove_headers: []) super( allowed: !!allowed, status: Integer(status), reason: reason&.to_s&.freeze, set_headers: normalize_headers(set_headers), remove_headers: Array(remove_headers).map { |name| normalize_header_name(name) }.uniq.freeze ) end
Builds a normalized trusted authorization decision.
Calls superclass method