Class: Ksef::HTTP::SystemWarning

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/ksef/http/system_warning.rb

Overview

Surfaces the X-System-Warning header the API sets on every successful response (docs/REFERENCE.md §5.5).

This is the Ministry's in-band channel for advisory notices — deprecations, forthcoming contract changes — and is not mentioned in DESIGN.md. Swallowing it would mean users only learn about a change when it breaks them.

Constant Summary collapse

HEADER =
"X-System-Warning"

Instance Method Summary collapse

Constructor Details

#initialize(app, logger: nil) ⇒ SystemWarning

Returns a new instance of SystemWarning.



16
17
18
19
# File 'lib/ksef/http/system_warning.rb', line 16

def initialize(app, logger: nil)
  super(app)
  @logger = logger
end

Instance Method Details

#on_complete(env) ⇒ Object



21
22
23
24
25
26
# File 'lib/ksef/http/system_warning.rb', line 21

def on_complete(env)
  warning = env.response_headers&.[](HEADER)
  return if warning.nil? || warning.to_s.strip.empty?

  @logger&.warn("[ksef_client] #{HEADER}: #{warning}")
end