Module: Spree::Api::V3::ChannelResolution

Extended by:
ActiveSupport::Concern
Included in:
Store::BaseController, Store::ResourceController
Defined in:
app/controllers/concerns/spree/api/v3/channel_resolution.rb

Overview

Resolves the active Spree::Channel for an API request and writes it into Spree::Current.channel so models, scopes, and serializers can read channel context without threading it through method args.

Resolution order:

  1. X-Spree-Channel header value matched against channels.code —or, if it looks like a prefixed ID (ch_…), against channels.id — scoped to the current store

  2. current_store.default_channel

The concern is a no-op if no channel matches — callers fall back to Spree::Current.channel‘s store-default behavior.

Constant Summary collapse

CHANNEL_HEADER =
'X-Spree-Channel'.freeze