Sha256: 3f44342fb09201f8d43624932b6f381b5c363290af94b28d75590ec104c5f620
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require 'prolog/dry_types' # All(?) Rack code is namespaced within this module. module Rack # Module includes our middleware components for managing service API versions. module ServiceApiVersioning # Builds an API Version data hash and encodes as JSON, for injection into a # Rack environment, normally with the key "COMPONENT_API_VERSION_DATA". class EncodedApiVersionData # Unpacks relevant attributes from passed-in input data class InputData < Dry::Struct::Value attribute :api_version, Types::Strict::Symbol attribute :input_data, Types::Hash def base_url version_data[:base_url] end def name input_data[:name] end def vendor_org content_type_parts[VENDOR_ORG_INDEX] end private # Index 0 will be `application/vnd`; index 1 the org name (eg, `acme`) VENDOR_ORG_INDEX = 1 private_constant :VENDOR_ORG_INDEX def content_type_parts version_data[:content_type].split('.') end def version_data input_data[:api_versions][api_version] end end # class EncodedApiVersionData::InputData end # class EncodedApiVersionData end end
Version data entries
2 entries across 2 versions & 1 rubygems