Class: Goliath::Rack::Formatters::YAML

Inherits:
Object
  • Object
show all
Includes:
AsyncMiddleware
Defined in:
lib/goliath/rack/formatters/yaml.rb

Overview

A YAML formatter.

Examples:

use Goliath::Rack::Formatters::YAML

Instance Method Summary collapse

Methods included from AsyncMiddleware

#call, #final_response?, #hook_into_callback_chain, #initialize

Methods included from Validator

safely, validation_error

Instance Method Details

#post_process(env, status, headers, body) ⇒ Object



13
14
15
16
17
18
# File 'lib/goliath/rack/formatters/yaml.rb', line 13

def post_process(env, status, headers, body)
  if yaml_response?(headers)
    body = [body.to_yaml]
  end
  [status, headers, body]
end

#yaml_response?(headers) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/goliath/rack/formatters/yaml.rb', line 20

def yaml_response?(headers)
  headers['Content-Type'] =~ %r{^text/yaml}
end